Automatically generates basic Django admin actions based on your models' fields
Install the package using pip
pip install django-auto-actions
There are two ways to integrate django-auto-actions
into your project:
from django.contrib.admin import ModelAdmin
from django_auto_actions import AutoActionsMixin
@admin.register(YourModel)
class YourModelAdmin(AutoActionsMixin, 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"]
Here's an example of what it might look like for a simple Homework
model:
And will display a success message like this:
pip install -r requirements.txt
docker compose up -d
python runtests.py
pip install -r requirements.txt
ruff check
You can also run ruff fix
to automatically fix some of the issues.
ruff check --fix
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!