Skip to main content

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 to django_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

django-changelist-toolbar-admin-0.4.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-changelist-toolbar-admin-0.4.3.tar.gz.

File metadata

File hashes

Hashes for django-changelist-toolbar-admin-0.4.3.tar.gz
Algorithm Hash digest
SHA256 400dd754456a9eb17f7f4e79a45b0beb95326eefd2aa6fa6385dd072ef2ecfc6
MD5 8c50c4e71fab7badaaa5ddfbb6d48242
BLAKE2b-256 39bcc5323d3d68ae3c157f8a6a8c3e40c214b1a8393fd5a46c737b131155908b

See more details on using hashes here.

File details

Details for the file django_changelist_toolbar_admin-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_changelist_toolbar_admin-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 28b9c0f004e48336a12f6547cb249e6284b7fa4bb99145a46cd633bc95a1a3bd
MD5 5716c6c55f1f80cfde6ddd96c20ed0ab
BLAKE2b-256 d787744c1328b4f19a264b316f51ee8cb7792b80645d34ac8840f0dc20891e68

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page