Skip to content
Permissions per field instead of per model for django
Find file
Latest commit dce9611 Oct 6, 2013 @specialunderwear Merge pull request #1 from PetrDlouhy/master
README additional note


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)

class HarddiskAdmin(admin.ModelAdmin)
    model = Harddisk, HarddiskAdmin)

or:, 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:

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