Skip to main content

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


Download files

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

Source Distribution

django_auto_permissions-0.1.14.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

django_auto_permissions-0.1.14-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file django_auto_permissions-0.1.14.tar.gz.

File metadata

File hashes

Hashes for django_auto_permissions-0.1.14.tar.gz
Algorithm Hash digest
SHA256 f31e2b4321cdec9b0242ab52b9389f742aaa89ac668b0d8a0970830b8726d45d
MD5 091a6a812197ca499d98c0fe9ce861f4
BLAKE2b-256 212d9c26f7c1d9fbc0ef3bdc0229b0fc4ae9cbe98f64759d0b1500c6e09fa18e

See more details on using hashes here.

Provenance

File details

Details for the file django_auto_permissions-0.1.14-py3-none-any.whl.

File metadata

File hashes

Hashes for django_auto_permissions-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 14f621040b8933b9bce62444779bb6c409d91e13b1efd5129d82af8d38c469ea
MD5 56e97bbc34abae4d487182c9cb41f990
BLAKE2b-256 2de4e6191d441971e209eb0988b3a2dfb76a17def3bb37c4e1186af27e3616c4

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page