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 changelist_toolbar.admin import DjangoChangelistToolbarAdmin
from .models import Category


class CategoryAdmin(DjangoChangelistToolbarAdmin, admin.ModelAdmin):
    list_display = ["name"]
    search_fields = ["name"]

    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.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

File details

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

File metadata

  • Download URL: django-changelist-toolbar-admin-0.3.0.tar.gz
  • Upload date:
  • Size: 5.2 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.43.0 CPython/3.8.2

File hashes

Hashes for django-changelist-toolbar-admin-0.3.0.tar.gz
Algorithm Hash digest
SHA256 44bf1b707855314793de9acc50feefcf15f646c6183cdcad7ee93dd8de93d97d
MD5 815dcb1a9101f905b0cdbc2268edb6dd
BLAKE2b-256 01f62ba0acf9408a9db2332dec8330157b72792aebda84620022c83331815b07

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