django-guardian 3.2.0
pip install django-guardian
Released:
Per object permissions for Django
Navigation
Verified details
These details have beenverified by PyPIProject links
GitHub Statistics
Maintainers
Unverified details
These details havenot been verified by PyPIProject links
Meta
- License: BSD License (BSD-2-Clause)
- Author:Chris Maggiuli, Bona Fide IT GmbH, Columbia University, SIS Development and Application Services
- Maintainer:Michael K., Chris Maggiuli, Bona Fide IT GmbH
- Tags django, permissions, authorization, object, row, level
- Requires: Python >=3.9
Classifiers
- Development Status
- Environment
- Framework
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
Project description
django-guardian
django-guardian is an implementation ofper-object permissions on topof Django’s authorization backend. Read an introduction to per-object permissionson djangoadvent articles.
Documentation
Online documentation is available athttps://django-guardian.readthedocs.io/.
Installation
To installdjango-guardian into your project run:
uvadddjango-guardianTIP: Not using a package manager like
uvorpoetryfor your django project? You probably should try them :). In the meantime,pip install django-guardianworks just fine too.
Configuration
We need to hookdjango-guardian into our project.
- Put
guardianinto yourINSTALLED_APPSat settings module:
INSTALLED_APPS=(...'guardian',)- Add extra authorization backend to your
settings.py:
AUTHENTICATION_BACKENDS=('django.contrib.auth.backends.ModelBackend','guardian.backends.ObjectPermissionBackend',)- Create
guardiandatabase tables by running:
python manage.py migrateUsage
After installation and project hooks we can finally use object permissionswith Django.
Lets start really quickly:
>>>fromdjango.contrib.auth.modelsimportUser,Group>>>jack=User.objects.create_user('jack','jack@example.com','topsecretagentjack')>>>admins=Group.objects.create(name='admins')>>>jack.has_perm('change_group',admins)False>>>fromguardian.shortcutsimportassign_perm>>>assign_perm('change_group',jack,obj=admins)<UserObjectPermission:admins|jack|change_group>>>>jack.has_perm('change_group',admins)TrueOf course our agent jack here would not be able tochange_group globally:
>>>jack.has_perm('change_group')FalseAdmin integration
Replaceadmin.ModelAdmin withGuardedModelAdmin for those modelswhich should have object permissions support within admin panel.
For example:
fromdjango.contribimportadminfrommyapp.modelsimportAuthorfromguardian.adminimportGuardedModelAdmin# Old way:#class AuthorAdmin(admin.ModelAdmin):# pass# With object permissions supportclassAuthorAdmin(GuardedModelAdmin):passadmin.site.register(Author,AuthorAdmin)Django Unfold integration
Users ofdjango-unfold will find thatguardian issupported out of the box via acontrib module.
Project details
Verified details
These details have beenverified by PyPIProject links
GitHub Statistics
Maintainers
Unverified details
These details havenot been verified by PyPIProject links
Meta
- License: BSD License (BSD-2-Clause)
- Author:Chris Maggiuli, Bona Fide IT GmbH, Columbia University, SIS Development and Application Services
- Maintainer:Michael K., Chris Maggiuli, Bona Fide IT GmbH
- Tags django, permissions, authorization, object, row, level
- Requires: Python >=3.9
Classifiers
- Development Status
- Environment
- Framework
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
Release historyRelease notifications |RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more aboutinstalling packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more aboutwheel file names.
Copy a direct link to the current filters
File details
Details for the filedjango_guardian-3.2.0.tar.gz.
File metadata
- Download URL:django_guardian-3.2.0.tar.gz
- Upload date:
- Size: 99.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 9e18ecd2e211b665972690c2d03d27bce0ea4932b5efac24a4bb9d526950a69e | |
| MD5 | b12fc05ba94744e033884f01736fb653 | |
| BLAKE2b-256 | e2f9bcff6a931298b9eb55e1550b55ab964fab747f594ba6d2d81cbe19736c5f |
Provenance
The following attestation bundles were made fordjango_guardian-3.2.0.tar.gz:
Publisher:release-publish.yml on django-guardian/django-guardian
- Statement:
- Statement type:
https://in-toto.io/Statement/v1 - Predicate type:
https://docs.pypi.org/attestations/publish/v1 - Subject name:
django_guardian-3.2.0.tar.gz - Subject digest:
9e18ecd2e211b665972690c2d03d27bce0ea4932b5efac24a4bb9d526950a69e - Sigstore transparency entry:523553411
- Sigstore integration time:
- Permalink:
django-guardian/django-guardian@4120d00c28c1b6d3bacb988f6db86bacf91ed0f1 - Branch / Tag:
refs/heads/main - Owner:https://github.com/django-guardian
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com - Runner Environment:
github-hosted - Publication workflow:
release-publish.yml@4120d00c28c1b6d3bacb988f6db86bacf91ed0f1 - Trigger Event:
workflow_dispatch
- Statement type:
File details
Details for the filedjango_guardian-3.2.0-py3-none-any.whl.
File metadata
- Download URL:django_guardian-3.2.0-py3-none-any.whl
- Upload date:
- Size: 134.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 0768565a057988a93fc4a1d93649c4a794abfd7473a8408a079cfbf83c559d77 | |
| MD5 | 06d463762d5c14aae3d718812d14f226 | |
| BLAKE2b-256 | 2f2363a7d868373a73d25c4a5c2dd3cce3aaeb22fbee82560d42b6e93ba01403 |
Provenance
The following attestation bundles were made fordjango_guardian-3.2.0-py3-none-any.whl:
Publisher:release-publish.yml on django-guardian/django-guardian
- Statement:
- Statement type:
https://in-toto.io/Statement/v1 - Predicate type:
https://docs.pypi.org/attestations/publish/v1 - Subject name:
django_guardian-3.2.0-py3-none-any.whl - Subject digest:
0768565a057988a93fc4a1d93649c4a794abfd7473a8408a079cfbf83c559d77 - Sigstore transparency entry:523553437
- Sigstore integration time:
- Permalink:
django-guardian/django-guardian@4120d00c28c1b6d3bacb988f6db86bacf91ed0f1 - Branch / Tag:
refs/heads/main - Owner:https://github.com/django-guardian
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com - Runner Environment:
github-hosted - Publication workflow:
release-publish.yml@4120d00c28c1b6d3bacb988f6db86bacf91ed0f1 - Trigger Event:
workflow_dispatch
- Statement type: