Automatically generates Django admin actions based on your model's fields
Project description
Django Auto Actions
Automatically generates basic Django admin actions based on your models' fields
Installation
Install the package using pip
pip install django-auto-actions
Usage
There are two ways to integrate django-auto-actions
into your project:
- Using AutoActionsMixin (recommended way)
from django.contrib.admin import ModelAdmin
from django_auto_actions import AutoActionsMixin
@admin.register(YourModel)
class YourModelAdmin(AutoActionsMixin, ModelAdmin):
...
- Using AutoActionsModelAdmin instead of ModelAdmin
from django_auto_actions import AutoActionsModelAdmin
@admin.register(YourModel)
class YourModelAdmin(AutoActionsModelAdmin):
...
With either method, django-auto-actions
will automatically generate admin actions for your model's BooleanFields, DateTimeFields, DateFields and TimeFields.
To exclude certain fields from having automatic admin actions generated, set the exclude_auto_actions
class-level attribute.
@admin.register(YourModel)
class YourModelAdmin(AutoActionsMixin, ModelAdmin):
exclude_auto_actions = ["is_example", "created_at"]
Example
Here's an example of what it might look like for a simple Homework
model:
And will display a success message like this:
Running Tests
pip install -r requirements.txt
docker compose up -d
python runtests.py
Support & Contributing
If you like it, please consider giving this project a star. If you’re using the package, let me know! You can also create an issue for any problems or suggestions. PRs are always welcome!
Authors
- Félix Gravel — @Flexonze
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
File details
Details for the file django_auto_actions-1.0.0.tar.gz
.
File metadata
- Download URL: django_auto_actions-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cd311d5804c5243432cdc1459c172f9eebe7fe3b32695aaddcfafb4726e679a |
|
MD5 | 2fb4d6cf79ca76627c9bbb8d5d96c3af |
|
BLAKE2b-256 | 685e4b0ace2698c12aeb66c527d82f9da03a61c63f461b25467aeac7e230c9f0 |
File details
Details for the file django_auto_actions-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: django_auto_actions-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1f96de0e53c1fc6e483d0d6f5fa2848e553850ccc43be3822fb68324d444f54 |
|
MD5 | 9248e9ad8ab2e24064221752c89c1d92 |
|
BLAKE2b-256 | 75d24f64bd73df65bdbe465e65a93b3e1c4969d754ec40b09b44c8cedbd14cc8 |