django-guardian is an implementation of per object permissions [1] on top
of Djangos authorization backend
Documentation
Online documentation is available at https:/django-guardian.readthedocs.io/.
Requirements
Python 3.5+
A supported version of Django (currently 2.2+)
GitHub Actions run tests against Django versions 2.2, 3.0, 3.1, 3.2, and main.
Installation
To install django-guardian simply run:
pip install django-guardian
Configuration
We need to hook django-guardian into our project.
Put guardian into your INSTALLED_APPS at settings module:
INSTALLED_APPS = (
...
guardian ,
)
Add extra authorization backend to your settings.py:
AUTHENTICATION_BACKENDS = (
django.contrib.auth.backends.ModelBackend , # default
guardian.backends.ObjectPermissionBackend ,
)
Create guardian database tables by running:
python manage.py migrate
Usage
After installation and project hooks we can finally use object permissions
with Django.
Lets start really quickly:
>>> fro
|