Skip to main content


Project description

Compose your permission classes for django-rest-framework.


To compose a new Permission class to be used by the django rest framework views you have to wrap the original class in a P class then can use the logical operators from python:

  • ~ (not)
  • | (or)
  • & (and)

This package also contains a few permission that can be used.

For example, when we want to create a permission class that allows read access to authenticated users and write access to superusers we can use the following code:

from rest_framework.permissions import IsAuthenticated
from drf_composable_permissions.p import P
from drf_composable_permissions.permissions import IsReadOnly, IsSuperuser

MyPermission = P(IsSuperuser) | (P(IsAuthenticated) & P(IsReadOnly))

Project details

Download files

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

Files for drf-composable-permissions, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size drf_composable_permissions-0.1-py2-none-any.whl (5.0 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size drf_composable_permissions-0.1-py3-none-any.whl (5.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size drf-composable-permissions-0.1.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page