Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Implementation of per object permissions for Django 1.2.

Project description

django-guardian is implementation of per object permissions [1] as authorization backend which is supported since Django 1.2. It won’t work with older Django releases.


To install django-guardian simply run:

pip install django-guardian


We need to hook django-guardian into our project.

  1. Put guardian into your INSTALLED_APPS at settings module:

  2. Add extra authorization backend:

        'django.contrib.auth.backends.ModelBackend', # default


After installation and project hooks we can finally use object permissions with Django.

Lets start really quickly:

>>> jack = User.objects.create_user('jack', '', 'topsecretagentjack')
>>> admins = Group.objects.create(name='admins')
>>> jack.has_perm('change_group', admins)
>>> UserObjectPermission.objects.assign('change_group', user=jack, obj=admins)
<UserObjectPermission: admins | jack | change_group>
>>> jack.has_perm('change_group', admins)

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

>>> jack.has_perm('change_group')


There is an online documentation available at

[1]Great peper about this feature is available at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-guardian, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size django-guardian-0.2.1.tar.gz (173.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page