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
File details
Details for the file django-rest-delegated-permissions-1.1.1.tar.gz
.
File metadata
- Download URL: django-rest-delegated-permissions-1.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abdec18e248e8f2b57b578d4cfa2ea8ac307fa8f39bdee11232733fd1e0bd095 |
|
MD5 | df6916cde26ce91a699fc932eb85bac4 |
|
BLAKE2b-256 | 4d04116846d38a7aa56fc2350c5fe9371e8359ccccbe8bcaaa872b09afac03cb |