Skip to main content

Add permissions per field instead of per model

Project description

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.

Project details


Download files

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

Source Distribution

django-finegrained-permissions-0.0.1.tar.gz (14.2 kB view details)

Uploaded Source

File details

Details for the file django-finegrained-permissions-0.0.1.tar.gz.

File metadata

File hashes

Hashes for django-finegrained-permissions-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ce92f5a7d0dcc623a5dce341f6b44d5a584608ec99c9f525c71d3acc7be2b58e
MD5 aa12536220e620ae33c3cae0b412459b
BLAKE2b-256 c050da2065a06c02b066ec2478de95ca5c1be2ce1d32f24f7106fc7c8d2ec0b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page