Provides custom button management function on changelist page of django admin site.
Project description
django-changelist-toolbar-admin
Provides custom button management function on changelist page of django admin site.
Install
pip install django-changelist-toolbar-admin
Usage
pro/settings.py
INSTALLED_APPS = [
...
'django_static_fontawesome',
'django_changelist_toolbar_admin',
...
]
- django_static_fontawesome is required, for already include the fontawesome css in Media's css settings.
app/admin.py
from django.contrib import admin
from django_changelist_toolbar_admin.admin import DjangoChangelistToolbarAdmin
from .models import Category
class CategoryAdmin(DjangoChangelistToolbarAdmin, admin.ModelAdmin):
list_display = ["name"]
search_fields = ["name"]
django_changelist_toolbar_buttons = [
"export",
"say_hi",
]
def export(self, request):
return "/export"
export.title = "Export"
export.icon = "fas fa-file-export"
export.target = "_blank"
def say_hi(self, request):
return {
"href": "javascript:alert('hi');",
"title": "Say Hi",
"icon": "fas fa-music",
}
admin.site.register(Category, CategoryAdmin)
- Another way is override
make_changelist_toolbar_button
get return the final buttons.
Releases
v0.4.0 2020/05/23
- Fix document.
- Rename configuration item
changelist_toolbar_buttons
todjango_changelist_toolbar_buttons
.
v0.3.0 2020/04/02
- The main class rename to DjangoChangelistToolbarAdmin. Mixin is a very simple abstract class that provides helper functions, but DjangoChangelistToolbarAdmin is complex base admin, so we remove the mixin suffix.
v0.2.0 2020/02/26
- App rename to django_changelist_toolbar_admin.
v0.1.0 2020/02/13
- First release.
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
Close
Hashes for django-changelist-toolbar-admin-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b724c9bda47656ef9e5e511a3c8c87576325474caa85d30f35fe7cad5fafe0e |
|
MD5 | aedf5551aca8664b759705caddb985c7 |
|
BLAKE2b-256 | 7d0db7abd84e96fed4ed2c2e94f95e256bfedf7eedeaa1f2f9785bc3da0f7e5e |