No project description provided
Project description
Easy Staff Required
A simple Django decorator to restrict view access to staff users.
Installation
Install the package using pip:
pip install django-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 django_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 django_staff_required import staff_required
@login_required
@staff_required
def my_view(request):
return render(request, "my_template.html")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for easy_staff_required-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee77cde065249ea677ce7b5756393fbc5849a095ec87667e5082c309ce658845 |
|
MD5 | be933fe18f2fd7185d09baf564a4bb8b |
|
BLAKE2b-256 | f50aa0b42edf5122f7865818df44f3e774d476473ff6912e105edb780802e811 |