Replaces the default action dropdown with buttons
Before:
After:
pip install django-admin-action-buttons
- Add
'admin_action_buttons',
toINSTALLED_APPS
- See "Usage" below.
There are two ways to apply django-admin-action-buttons change:
- Blanket-style to all models in the admin
- Selectively
To apply the change across the entire admin:
-
Add
'admin_action_buttons.context_processors.admin_action_buttons'
tocontext_processors
For example:TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "OPTIONS": { "context_processors": [ # defaults: "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", # custom: "admin_action_buttons.context_processors.admin_action_buttons", ], }, }, ]
Docs: https://docs.djangoproject.com/en/3.1/topics/templates/#django.template.backends.django.DjangoTemplates The default list is documented here: https://docs.djangoproject.com/en/3.1/topics/templates/#django.template.backends.django.DjangoTemplates
-
Make sure that
admin_action_buttons
inINSTALLED_APPS
comes BEFOREdjango.contrib.admin
The blanket change cen be disabled via settings:
ADMIN_ACTION_BUTTONS_ALWAYS = False
Add the mixin to any ModelAdmin
you wish to tweak:
from admin_action_buttons import ActionButtonsMixin
class MyModelAdmin(ActionButtonsMixin, admin.ModelAdmin):
...
Alternatively, you can add the JS media file directly:
class MyModelAdmin(admin.ModelAdmin):
...
class Media:
js = [
...
'admin_action_buttons/admin_action_buttons.js',
]
css = {
'all': [
'admin_action_buttons/admin_action_buttons.css',
...
],
}
This is a pure JS & CSS implementation.
Please report any problems via Github issues. PRs welcome.