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_button",
"say_hi_button",
]
def export_button(self, request):
return "/export"
export_button.title = "Export"
export_button.icon = "fas fa-file-export"
export_button.target = "_blank"
def say_hi_button(self, request):
return {
"href": "javascript:alert('hi');",
"title": "Say Hi",
"icon": "fas fa-music",
}
admin.site.register(Category, CategoryAdmin)
- A button function must returns a Button instance, dict button info, or href.
- Another way is override
make_changelist_toolbar_button
get return the final buttons.
Releases
v0.4.5
- Add button classes support.
v0.4.3
- Doc update.
- Add django-app-requires support.
v0.4.0
- Fix document.
- Rename configuration item
changelist_toolbar_buttons
todjango_changelist_toolbar_buttons
.
v0.3.0
- 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
- App rename to django_changelist_toolbar_admin.
v0.1.0
- 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
Built Distribution
File details
Details for the file django-changelist-toolbar-admin-0.4.5.tar.gz
.
File metadata
- Download URL: django-changelist-toolbar-admin-0.4.5.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd38cdb4ad11f2efb7305b7c77d6de644add34a3a1f9695b96050fbd927070de |
|
MD5 | 2553f2ae3b13283961a2fcac07c9855d |
|
BLAKE2b-256 | 479963e0156a87422d8112eb372bfd373dd117f4deafae69dce17af77dd17085 |
File details
Details for the file django_changelist_toolbar_admin-0.4.5-py3-none-any.whl
.
File metadata
- Download URL: django_changelist_toolbar_admin-0.4.5-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a147ac8c7c1addcab0555187306ce92d3a6dc0228c8e64b141e87b638862251 |
|
MD5 | 15479b9c637a5bc70bee62215522606c |
|
BLAKE2b-256 | c2691ea95946bdbe8a28ae6630898565cf50cbf81ed8ea902ede6c439e4ac4d5 |