Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Permissions per field instead of per model for django

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 fgp Updated docs and corrected unhelpful error message. June 30, 2011
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 requirements.txt Working example August 22, 2010
Octocat-spinner-32 setup.py
README.rst

Django finegrained permissions

Add permissions per field instead of per model:

from django.db import models
from django.contrib import admin
import fgp

@fgp.guard('slave', 'master', name='can_edit_master_slave')
class Harddisk(models.Model):
    type = models.CharField(max_length=255)
    slave = models.BooleanField(default=False)
    master = models.BooleanField(default=True)

@fgp.enforce
class HarddiskAdmin(admin.ModelAdmin)
    model = Harddisk

admin.site.register(Harddisk, HarddiskAdmin)

or:

admin.site.register(Harddisk, fgp.enforce(Harddisk, admin.ModelAdmin))

Note that you need to set model even when the admin class is not an inline admin.

To add permissions to admin settings execute:

./manage.py syncdb --all
Something went wrong with that request. Please try again.