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

django-changelist-toolbar-admin-0.4.0.tar.gz (4.6 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: django-changelist-toolbar-admin-0.4.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for django-changelist-toolbar-admin-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4b724c9bda47656ef9e5e511a3c8c87576325474caa85d30f35fe7cad5fafe0e
MD5 aedf5551aca8664b759705caddb985c7
BLAKE2b-256 7d0db7abd84e96fed4ed2c2e94f95e256bfedf7eedeaa1f2f9785bc3da0f7e5e

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