Skip to main content

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


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.4.0.tar.gz.

File metadata

  • Download URL: django-rest-delegated-permissions-1.4.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.3

File hashes

Hashes for django-rest-delegated-permissions-1.4.0.tar.gz
Algorithm Hash digest
SHA256 e96ff4416401d15c91a794171fdc147239f5c15ba5e2c5383aee00096d4b9c39
MD5 018f91efe1afbd49a0e178e1793d3900
BLAKE2b-256 8faad6927086804306ac7bc4da43e9bb07ddc3e36e1dc78d1d1329e2f2ff8b0b

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