Easy Staff Required
A simple Django decorator to restrict view access to staff users.
Installation
Install the package using pip:
pip install easy-staff-required
Usage
After installing the package, you can use the @staff_required decorator in your Django views to restrict access to staff users. Here's an example:
from django.shortcuts import render
from easy_staff_required import staff_required
@staff_required
def my_view(request):
return render(request, "my_template.html")
The @staff_required decorator checks if the user is authenticated and has the is_staff attribute set to True. If the user is not a staff member, a PermissionDenied exception is raised.
You can also use the @staff_required decorator in combination with Django's built-in @login_required decorator:
from django.contrib.auth.decorators import login_required
from easy_staff_required import staff_required
@login_required
@staff_required
def my_view(request):
return render(request, "my_template.html")
Release files for easy-staff-required 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| easy-staff-required-0.4.tar.gz | 2.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easy_staff_required-0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.8 kB
Release files / easy-staff-required-0.4.tar.gz
| Download URL | easy-staff-required-0.4.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
964cc11a365dc6306a209dafdecc9ea8eac1104720c6418d401b33163e2773a3
|
|
BLAKE2b-256 checksum How to use checksums |
085633f13ac051112c0222f34f689976bfc682fe8513efe304e83fc4fdb4da2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / easy_staff_required-0.4-py3-none-any.whl
| Download URL | easy_staff_required-0.4-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62bd46f5abd7a5b5004aa85e8f1775582f0bc20f1f50fc6002041562a4edbc04
|
|
BLAKE2b-256 checksum How to use checksums |
ad8e23b82e3102dfd480aab9682f1c8d1aa3d758b13d630e0af70b0cd6ff06d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|