
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
django-admin-row-actions
Advanced tools
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
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.
Install from PyPI:
pip install django-admin-row-actions
or install using pip and git:
pip install git+https://github.com/DjangoAdminHackers/django-admin-row-actions.git
Add to INSTALLED_APPS:
INSTALLED_APPS = [
...
'django_admin_row_actions',
...
]
Add the mixin to your ModelAdmin:
from django_admin_row_actions import AdminRowActionsMixin
...
class ExampleAdmin(AdminRowActionsMixin, admin.ModelAdmin):
...
Define a get_row_actions
method on your ModelAdmin
def 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.
Inspired (and code based on): django-object-actions
Includes parts of jquery-dropdown; credits go to Cory LaViska.
FAQs
Add action buttons to individual rows in the Django Admin
We found that django-admin-row-actions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.