A Django app to make dropdown customized actions
Project description
Equality Django Admin Row Actions
Allows you to easily define a drop-down 'actions' menu that is appended as the final column in your model's changelist and perform actions on that row.
Menu items can call urls or methods, can be disabled, have tooltips, etc.
I've extracted this from code written for http://hireablehq.com/. The admin there has Bootstrap available but I've modified this version to use a standalone jQuery dropdown.
Installation
-
Install from PyPI:
pip install eq-django-admin-row-actions
-
Add to INSTALLED_APPS:
INSTALLED_APPS = [ ... 'eq_django_admin_row_actions', ... ]
-
Add the mixin to your ModelAdmin:
from eq_django_admin_row_actions import AdminRowActionsMixin ... class ExampleAdmin(AdminRowActionsMixin, admin.ModelAdmin): ...
-
Define a
get_row_actions
method on your ModelAdmindef get_row_actions(self, obj): row_actions = [ { 'label': 'Edit', 'url': obj.get_edit_url(), 'enabled': obj.status is not 'cancelled', }, { 'label': 'Download PDF', 'url': obj.get_pdf_url(), }, { 'label': 'Convert', 'url': reverse('convert_stuff', args=[obj.id]), 'tooltip': 'Convert stuff', }, { 'divided': True, 'label': 'Cancel', 'action': 'mark_cancelled', }, ] row_actions += super(ExampleAdmin, self).get_row_actions(obj) return row_actions
The first three menu items are simple links to a url you provide by whatever means you choose.
The final one defines 'action' instead of 'url'. This should be the name of a callable on your ModelAdmin
or Model
class (similar to ModelAdmin.list_display).
You can add mouseover tooltips to each individual actions with the 'tooltip' dictionary key, and enable/disable individual actions for each individual object with the 'enabled'.
Special option 'divided' can be passed to any item to display horizontal rule above it.
Credits
Inspired (and code based on): django-object-actions
Includes parts of jquery-dropdown; credits go to Cory LaViska.
Inspired (and code based on): django-admin-row-actions
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
File details
Details for the file eq-django-admin-row-actions-0.0.9.tar.gz
.
File metadata
- Download URL: eq-django-admin-row-actions-0.0.9.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fde2e03a075f99c0f35f21f01164e745a64264be80b4f8a6374739cf1df8cff8 |
|
MD5 | c445fe4e5b6318a4f284749b39ca4da1 |
|
BLAKE2b-256 | 74941ab9397c46dd75687c3250b682ce2c828596ddcd81e95ee48600ef3b154c |