Automated permission generation for Django viewsets
Project description
Django Auto Permissions
Django Auto Permissions is a Django library designed to automatically generate and apply permissions for custom methods defined in Django Rest Framework viewsets. It simplifies the process of managing permissions, ensuring that each custom viewset method has its corresponding permission without manually creating them.
Features
- Automatic Permission Generation: Dynamically creates permissions for custom methods within registered viewsets.
- Easy Integration: Seamlessly integrates with Django's existing permission framework.
- Django Signals for Automation: Utilizes Django signals to automate permission creation, especially after migrations.
- Comprehensive Testing: Well-tested to ensure reliability.
- Simple Registration Process: Easily register your viewsets with the library.
Installation
Install django_auto_permissions
via pip:
pip install django_auto_permissions
Setup
After installation, add auto_permissions
to your INSTALLED_APPS
in Django's settings.py
:
INSTALLED_APPS = [
# ... other installed apps ...
'django_auto_permissions',
]
Usage
Registering Viewsets
In your viewsets file, register each viewset with its corresponding model using ViewsetRegistrar
.
# In your viewsets.py
from django_auto_permissions.registration import ViewsetRegistrar
from myapp.models import MyModel
from myapp.viewsets import MyViewSet
# Register the viewset and model
ViewsetRegistrar.register(MyViewSet, MyModel)
This should be done before running your Django project, ideally in a module that gets loaded on startup, such as views.py
or models.py
.
Checking Generated Permissions
Once your Django project is running, the library will automatically generate and register permissions for your custom viewset methods. These permissions can be viewed and managed in the Django admin interface.
Contributing
Contributions to django_auto_permissions
are welcome! Please read our contributing guidelines for submitting pull requests.
License
This project is licensed under the MIT License.
Contact
For support or queries, reach out to [Your Email or Contact Information].
Acknowledgements
- Thanks to the Django and Django Rest Framework communities for their invaluable resources.
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
Hashes for django_auto_permissions-0.1.20.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13f1e5a7394a1051d2b0cd1927077c33ff93748d7ce6cd8d5ddc695d21272853 |
|
MD5 | e7faad873b388a0dd3d83c7ac1961a2a |
|
BLAKE2b-256 | a5f365dc10dfd78124f0e57fe38a1383c5c50ec8eeb919feddbbb4f1e67f77d4 |
Hashes for django_auto_permissions-0.1.20-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91bc1c4b5264654f8f6cd63f079aa45c683d370301b7ff5b57e9ec085f860faa |
|
MD5 | b86656e6a3258a4b61e8644e9f733565 |
|
BLAKE2b-256 | 9114e621caece7ad106e581106391a36b361dc9e42deefef119aa4b9d76f8099 |