Taking (delegating) REST permissions from a model instance to a model pointed by ForeignKey/m2m
Project description
Delegate django rest framework object permissions to an object pointed by foreign key/m2m
Sample: set up permissions so that anyone having django/django guardian permissions on Invoice will have the same set of permissions on its address:
class Address(models.Model):
... address fields
class Invoice(models.Model):
address = models.OneToOneField(Address, related_name='invoice')
... invoice fields
perms = RestPermissions()
@perms.apply(permissions=DelegatedPermissions(perms, "invoice")
class AddressViewSet(ModelViewSet):
queryset = Address.objects.all()
serializer = AddressSerializer
...
@perms.apply() # implicitely adds django model permissions and guardian permissions
class InvoiceViewSet(ModelViewSet):
queryset = Invoice.objects.all()
serializer = InvoiceSerializer
...
See docs and API at github.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-rest-delegated-permissions-1.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4d5950ce8caf5ca01b9eb2148937a6a9809123a39de485580ab5f5a4275feed |
|
MD5 | a40629bbe70c65e5e99d28102d84c845 |
|
BLAKE2b-256 | 8a2738f459b3d5a14ad731b311a9d74ce5da1a4f61df330b335b6a9da8ceb912 |