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 = [
    ...
    'fontawesome',
    'changelist_toolbar',
    ...
]

app/admin.py

from django.contrib import admin
from changelist_toolbar.admin import ChangelistToolbarAdminMixin
from .models import Category


class CategoryAdmin(ChangelistToolbarAdminMixin, 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)

Releases

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.1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

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