Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-guardian

How to install django-guardian

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-guardian
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0.4
1.1.1Never BuiltWhy not?
1.0.4 Available View build log
1.0.3 Available View build log
1.0.2 Available View build log
1.0.1 Available View build log
1.0.0 Available View build log
1.0.0.pre Available View build log
1.0.0.beta2 Available View build log
1.0.0.beta1 Available View build log
1.0.0.alpha2 Available View build log
0.2.3 Available View build log
0.2.2 Available View build log
0.2.1 Available View build log
0.1.1 Available View build log
0.1.0 Available View build log
Windows (64-bit)
1.0.4
1.1.1Never BuiltWhy not?
1.0.4 Available View build log
1.0.3 Available View build log
1.0.2 Available View build log
1.0.1 Available View build log
1.0.0 Available View build log
1.0.0.pre Available View build log
1.0.0.beta2 Available View build log
1.0.0.beta1 Available View build log
1.0.0.alpha2 Available View build log
0.2.3 Available View build log
0.2.2 Available View build log
0.2.1 Available View build log
0.1.1 Available View build log
0.1.0 Available View build log
Mac OS X (10.5+)
1.0.4
1.1.1Never BuiltWhy not?
1.0.4 Available View build log
1.0.3 Available View build log
1.0.2 Available View build log
1.0.1 Available View build log
1.0.0 Available View build log
1.0.0.pre Available View build log
1.0.0.beta2 Available View build log
1.0.0.beta1 Available View build log
1.0.0.alpha2 Available View build log
0.2.3 Available View build log
0.2.2 Available View build log
0.2.1 Available View build log
0.1.1 Available View build log
0.1.0 Available View build log
Linux (32-bit)
1.1.1 Available View build log
1.0.4 Available View build log
1.0.3 Available View build log
1.0.2 Available View build log
1.0.1 Available View build log
1.0.0 Available View build log
1.0.0.pre Available View build log
1.0.0.beta2 Available View build log
1.0.0.beta1 Available View build log
1.0.0.alpha2 Available View build log
0.2.3 Available View build log
0.2.2 Available View build log
0.2.1 Available View build log
0.1.1 Available View build log
0.1.0 Available View build log
Linux (64-bit)
1.1.1 Available View build log
1.0.4 Available View build log
1.0.3 Available View build log
1.0.2 Available View build log
1.0.1 Available View build log
1.0.0 Available View build log
1.0.0.pre Available View build log
1.0.0.beta2 Available View build log
1.0.0.beta1 Available View build log
1.0.0.alpha2 Available View build log
0.2.3 Available View build log
0.2.2 Available View build log
0.2.1 Available View build log
0.1.1 Available View build log
0.1.0 Available View build log
 
License
BSD
Dependencies
Lastest release
version 1.1.1 on Jun 1st, 2013
https://secure.travis-ci.org/lukaszb/django-guardian.png?branch=master

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.

Documentation

Online documentation is available at

http://packages.python.org/django-guardian/ or http://django-guardian.rtfd.org/

Installation

To install django-guardian simply run:

pip install django-guardian

Configuration

We need to hook django-guardian into our project.

  1. Put guardian into your INSTALLED_APPS at settings module:

    INSTALLED_APPS = (
       ...
       'guardian',
    )
    
  2. Add extra authorization backend:

    AUTHENTICATION_BACKENDS = (
        'django.contrib.auth.backends.ModelBackend', # default
        'guardian.backends.ObjectPermissionBackend',
    )
    
  3. Configure anonymous user ID

    ANONYMOUS_USER_ID = -1
    

Usage

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

Lets start really quickly:

>>> jack = User.objects.create_user('jack', 'jack@example.com', 'topsecretagentjack')
>>> admins = Group.objects.create(name='admins')
>>> jack.has_perm('change_group', admins)
False
>>> UserObjectPermission.objects.assign_perm('change_group', user=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 to change_group globally:

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

Admin integration

Replace admin.ModelAdmin with GuardedModelAdmin for those models which should have object permissions support within admin panel.

For example:

from django.contrib import admin
from myapp.models import Author
from guardian.admin import GuardedModelAdmin

# Old way:
#class AuthorAdmin(admin.ModelAdmin):
#    pass

# With object permissions support
class AuthorAdmin(GuardedModelAdmin):
    pass

admin.site.register(Author, AuthorAdmin)
[1]Great paper about this feature is available at djangoadvent articles.

Subscribe to package updates

Last updated Jun 1st, 2013

Download Stats

Last month:17

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.