Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
PyPI

django-guardian 3.2.0

pip install django-guardian

Latest version

Released:

Per object permissions for Django

Unverified details

These details havenot been verified by PyPI
Project links
Meta

Project description

django-guardian

TestsPyPI versionPython versionsPublished on Django Packages

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-guardian

TIP: Not using a package manager likeuv orpoetry for your django project? You probably should try them :). In the meantime,pip install django-guardian works just fine too.

Configuration

We need to hookdjango-guardian into our project.

  1. Putguardian into yourINSTALLED_APPS at settings module:
INSTALLED_APPS=(...'guardian',)
  1. Add extra authorization backend to yoursettings.py:
AUTHENTICATION_BACKENDS=('django.contrib.auth.backends.ModelBackend','guardian.backends.ObjectPermissionBackend',)
  1. Createguardian database tables by running:
python manage.py migrate

Usage

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)True

Of course our agent jack here would not be able tochange_group globally:

>>>jack.has_perm('change_group')False

Admin 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

Unverified details

These details havenot been verified by PyPI
Project links
Meta

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

django_guardian-3.2.0.tar.gz (99.9 kBview details)

UploadedSource

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

django_guardian-3.2.0-py3-none-any.whl (134.7 kBview details)

UploadedPython 3

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

Hashes for django_guardian-3.2.0.tar.gz
AlgorithmHash digest
SHA2569e18ecd2e211b665972690c2d03d27bce0ea4932b5efac24a4bb9d526950a69e
MD5b12fc05ba94744e033884f01736fb653
BLAKE2b-256e2f9bcff6a931298b9eb55e1550b55ab964fab747f594ba6d2d81cbe19736c5f

See more details on using hashes here.

Provenance

The following attestation bundles were made fordjango_guardian-3.2.0.tar.gz:

Publisher:release-publish.yml on django-guardian/django-guardian

Attestations:Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the filedjango_guardian-3.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_guardian-3.2.0-py3-none-any.whl
AlgorithmHash digest
SHA2560768565a057988a93fc4a1d93649c4a794abfd7473a8408a079cfbf83c559d77
MD506d463762d5c14aae3d718812d14f226
BLAKE2b-2562f2363a7d868373a73d25c4a5c2dd3cce3aaeb22fbee82560d42b6e93ba01403

See more details on using hashes here.

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

Attestations:Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security SponsorDatadog MonitoringDepot Continuous IntegrationFastly CDNGoogle Download AnalyticsPingdom MonitoringSentry Error loggingStatusPage Status page

[8]ページ先頭

©2009-2025 Movatter.jp