Automatically set-up filters and permissions for Django's DRY Rest Permissions
Project description
django-autodrp
Automatically set-up filters and permissions for Django's DRY Rest Permissions
Quick Start
- Run
pip install django-autodrp - Add 'autodrp' to your INSTALLED_APPS in your settings below all the apps you wish to use AutoDRP for (failing to add django-autodrp after the apps that will use it will result in the autoconfiguration of AutoDRP not running).
INSTALLED_APPS = [
# Django apps / packages
'all-django-apps',
# Your apps
'yourapp'
]
INSTALLED_APPS = [
# Django apps / packages
'all-django-apps',
# Your apps
'yourapp',
'autodrp', # <- Here
]
- Add the following (or replace your already existing has_blank_permission functions) to any models you with to use AutoDRP for (either is optional):
DRY_GLOBAL_PERMISSIONS = {
('read', 'write'): True
}
DRY_OBJECT_PERMISSIONS = {
('read', 'write'): True
}
Indicating read with a value of true is the same as:
@staticmethod
def has_read_permission(request):
return True
- Import
AutoDRPFilterviafrom autodrp.filters import AutoDRPFilter, and add it to yourfilter_backendson your viewset like so:
from autodrp.filters import AutoDRPFilter
class ProjectViewSet(viewsets.ModelViewset):
queryset = Project.objects.all()
permission_classes = (DRYPermissions,)
filter_backends = [AutoDRPFilter]
- You now are using AutoDRP permissions and filters.
Consult the wiki for a definitive tutorial and explanation of AutoDRP.
Motivation for this project
I've found DRY Rest Permissions to be a great asset but rather verbose. I hope to make working with DRY Rest Permissions easier by consolidating filter and permission functionality into a simple and terse feature.
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-autodrp-1.0.0.tar.gz.
File metadata
- Download URL: django-autodrp-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8205add9ef4ff218fa6e0ca72cf5c4abee31863a2d7f097f8ff6b78af9cc071a
|
|
| MD5 |
094505b04b94a01965b0023deea6bdd3
|
|
| BLAKE2b-256 |
a6261c89a22df245f777d60558158af5ff0f04763f7f3c2bee35c28d21204549
|
File details
Details for the file django_autodrp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_autodrp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8db15d64b964cbfdbf3f1cfb583e8120650d42ed62052d331d43467efda8fdcc
|
|
| MD5 |
c625002a4fdc0098161f83cab11327c2
|
|
| BLAKE2b-256 |
5689f8fd67111b2d917fc8fd1a7cc6e005f85891e4a5f863d1169fdf6b2e20fa
|