Skip to main content

django-object-tools-admin

Add toolbar in every item line in django's changelist view, and on top of django's changeform view.

Install

pip install django-object-toolbar-admin

Usage

pro/settings.py

INSTALLED_APPS = [
    ...
    'django_static_fontawesome',
    'django_object_toolbar_admin',
    ...
]
  • Add django_static_fontawesome and django_object_toolbar_admin applications in INSTALLED_APPS.

app/admin.py

from django.contrib import admin
from django_object_toolbar_admin.admin import DjangoObjectToolbarAdmin
from .models import Category

class CategoryAdmin(DjangoObjectToolbarAdmin, admin.ModelAdmin):
    list_display = ["name", "django_object_toolbar", "my_toolbar"]

    django_object_toolbar_changeform_buttons = [
        "print",
        "export",
        "bye",
    ]
    # define default toolbar
    django_object_toolbar_buttons = [
        "print",
        "export",
        'bye',
    ]

    def print(self, obj):
        return "/print"
    print.icon = "fas fa-print"
    print.title = "Print"
    print.help_text = "Print the object information..."
    
    def export(self, obj):
        return "/export"
    export.icon = "fas fa-save"
    export.title = "Export"

    # define my toolbar
    def my_toolbar(self, obj):
        return self.get_django_object_toolbar("my_toolbar_buttons", obj)
    my_toolbar.short_description = "My Toolbar"

    my_toolbar_buttons = [
        "delete",
        "say_hi",
    ]

    def delete(self, obj):
        return "/delete"
    delete.icon = "fas fa-trash"
    delete.title = "Delete"

    def say_hi(self, obj):
        return "javascript:alert('hi {}');".format(obj.pk)
    say_hi.icon = "fas fa-music"
    say_hi.title = "Say Hi!"

admin.site.register(Category, CategoryAdmin)
  • Buttons in django_object_toolbar_changeform_buttons will display on top of changeform view.
  • Buttons in django_object_toolbar_buttons or my_toolbar_buttons will display in every line in changelist view. You need to put django_object_toolbar or my_toolbar in list_display.
  • A button can be a method of admin or a method of model instance.
  • A button method returns the link of the button.
  • A button method tasks extra configs:
    • button.title
    • button.icon
    • button.help_text
    • button.target
    • button.klass

Releases

v0.1.0

  • First release.

v0.1.1

  • Fix Button.from_dict calling problem.
  • Add i18n.
  • Add app_requires.

v0.1.2

  • Doc update.

v0.1.3

  • Doc update.

Release files for django-object-toolbar-admin 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-object-toolbar-admin 0.1.3
File Size Uploaded
django_object_toolbar_admin-0.1.3.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-object-toolbar-admin 0.1.3
File Interpreter ABI Platform
django_object_toolbar_admin-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / django_object_toolbar_admin-0.1.3.tar.gz

Download URL django_object_toolbar_admin-0.1.3.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e2570888b256adabcd748870777a494d5bfdcc91fd0e0763c78b61135e07e400
BLAKE2b-256 checksum
How to use checksums
06c3542cba84ca93b51e27c049b3ad018fd17c915a63d5191e9e6fd8632596b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / django_object_toolbar_admin-0.1.3-py3-none-any.whl

Download URL django_object_toolbar_admin-0.1.3-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62e747de0ae90aed288be3163eef1024ee7e215016b7529ffd406bd58f774729
BLAKE2b-256 checksum
How to use checksums
0c4a5b727a86c7c95f36bb2550e720963b609179579c79cb4d9cff0bf58d02cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page