drf-permission-rules
permission rules for DRF base on drf access policy
Installation
pip install drf-permission-rules
Usage
ViewSet permissions
class UserViewSet(ModelViewSet, PermissionsActionMixin):
...
@action(methods=["GET", "POST"], detail=False)
def some_action(self, request, *args, **kwargs):
...
GET /api/users/permissions
Response:
{
"create": true,
"list": true,
"some_action": false
}
Multiple ViewSet permissions
# views.py
class UserViewSet(ModelViewSet, PermissionsActionMixin):
...
class BookViewSet(ModelViewSet, PermissionsActionMixin):
...
class AuthorViewSet(ModelViewSet, PermissionsActionMixin):
...
# urls.py
urlpatterns = [
...
path("api/", include("permission_rules.urls")),
]
GET /api/users/permissions
Response:
{
"User": {
"create": true
"list": true,
"some_action": false
}
"Book": {
"create": true,
"list": true
},
"Author": {
"create": false,
"list": true
}
}
Speedup
You can get permissions from a file instead of a database.
# settings.py
PERMISSION_RULES_SETTINGS = {
"use_file_instead_db": true,
"permission_rules_file_path": "/path/to/permissions.json"
}
Metadata
Release files for drf-permission-rules 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| drf_permission_rules-0.5.1.tar.gz | 63.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| drf_permission_rules-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 78.9 kB
Release files / drf_permission_rules-0.5.1.tar.gz
| Download URL | drf_permission_rules-0.5.1.tar.gz |
|---|---|
| Size | 63.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5bdf2c2bb2352eb595ef7d1cad3dc3b3fe96af22dd79bbd9efea60a88ae3189e
|
|
BLAKE2b-256 checksum How to use checksums |
ea36c67f2a0a07fc7d6f86088052d24b8bed19ea3b8fbf9256290d764fa0bb71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / drf_permission_rules-0.5.1-py3-none-any.whl
| Download URL | drf_permission_rules-0.5.1-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e1b98a201a5b887d1a4836431a941e20d8619530c162ccaa84cd25f7fd6b1d0
|
|
BLAKE2b-256 checksum How to use checksums |
7a012f7d0d3156a1a40b70001d4709345c8a85375354675dfebb24112ec1c25c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|