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_buttonget return the final buttons.
Releases
v0.4.7
- Doc update.
v0.4.6
- Add data attr for toolbar button.
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_buttonstodjango_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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_changelist_toolbar_admin-0.4.7.tar.gz.
File metadata
- Download URL: django_changelist_toolbar_admin-0.4.7.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
907c465bdba6c19e774e7647535e5f021215ed4c2ac20cd10e153932bfdbcf58
|
|
| MD5 |
bbd6a98ab0448242985a55e7c613d95e
|
|
| BLAKE2b-256 |
7dee084af6cc7a4ee3b40fbc7e928137f2763e5e544b1409199546f803aa97f7
|
File details
Details for the file django_changelist_toolbar_admin-0.4.7-py3-none-any.whl.
File metadata
- Download URL: django_changelist_toolbar_admin-0.4.7-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72298ff624785ea798b01948a7793bc5a137d3efcdfd2abb4bb0059429414a41
|
|
| MD5 |
377a66374960a78df046d26f4ec17898
|
|
| BLAKE2b-256 |
404d7e4cf001fbe29ffea1e6418363f25a753602d02967a3f6d1c980143675f6
|