UNKNOWN
Project description
Compose your permission classes for django-rest-framework.
Usage
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
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
Built Distributions
Close
Hashes for drf-composable-permissions-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3d8bfebc6c5a5c440846e1adf6479041056d7e3e153ef7d626e01d50d35517e |
|
MD5 | 9e328244ae0ff40c58dcd02d5c8a51a0 |
|
BLAKE2b-256 | 4ce230a074f596620bf30a17e3b744ef8514e720df968d5b1ccabe8957208de5 |
Close
Hashes for drf_composable_permissions-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e357ab056fdd452801f742999a3fe89b75746e27692e73b49f1f5fa624b2299 |
|
MD5 | 2595583282cdb87359e15a6223937267 |
|
BLAKE2b-256 | 190f0c70e80a70326b8bdf69053f7d5b2cfd69793d78507219f8cb596771b82d |
Close
Hashes for drf_composable_permissions-0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0da44a299f18b971b92a9a0aab0f3701325c8d8751c0ffa7c4f5f448a8263ca |
|
MD5 | 851bd5a1ae25dcba43639268dbf5ded7 |
|
BLAKE2b-256 | 528ad7a7a4fb51f84f6eaf2621adb88565b29943a2217bfd4c7e94219b249ff7 |