skip to navigation
skip to content

Not Logged In

django-finegrained-permissions 0.0.1

Add permissions per field instead of per model

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.

 
File Type Py Version Uploaded on Size
django-finegrained-permissions-0.0.1.tar.gz (md5) Source 2011-08-22 13KB
  • Downloads (All Versions):
  • 40 downloads in the last day
  • 145 downloads in the last week
  • 265 downloads in the last month