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.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.3.tar.gz
.
File metadata
- Download URL: django-changelist-toolbar-admin-0.4.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 400dd754456a9eb17f7f4e79a45b0beb95326eefd2aa6fa6385dd072ef2ecfc6 |
|
MD5 | 8c50c4e71fab7badaaa5ddfbb6d48242 |
|
BLAKE2b-256 | 39bcc5323d3d68ae3c157f8a6a8c3e40c214b1a8393fd5a46c737b131155908b |
File details
Details for the file django_changelist_toolbar_admin-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: django_changelist_toolbar_admin-0.4.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28b9c0f004e48336a12f6547cb249e6284b7fa4bb99145a46cd633bc95a1a3bd |
|
MD5 | 5716c6c55f1f80cfde6ddd96c20ed0ab |
|
BLAKE2b-256 | d787744c1328b4f19a264b316f51ee8cb7792b80645d34ac8840f0dc20891e68 |