Add toolbar in every item line in django's changelist view, and on top of django's changeform view.
Project description
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
ormy_toolbar_buttons
will display in every line in changelist view. You need to putdjango_object_toolbar
ormy_toolbar
inlist_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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-object-toolbar-admin-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0698b0ecb38ea37f6aa1f137b12e079ba96f90368ea90bcd3d7ff9de87360102 |
|
MD5 | 849ecad019054ae75f5e65ed21d67319 |
|
BLAKE2b-256 | 109a09a16fd541ac6b92737eac9debeb64b85a69128945e757b488d95cf8d2c5 |
Close
Hashes for django_object_toolbar_admin-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5906bbe8690034dba3aeede9688985b45e894dda89b503b51e9a6ededf05df3f |
|
MD5 | e808f8fd34358b6611e4acfa3cfaed01 |
|
BLAKE2b-256 | d5db8d22205081054a7c6caebaa8adb1f77b241a93d9045fe38b208e95f82cc3 |