Skip to main content

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

  1. 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
    
  2. Add to INSTALLED_APPS:

    INSTALLED_APPS = [
        ...
        'django_admin_row_actions',
        ...
    ]
    
  3. Add the mixin to your ModelAdmin:

    from django_admin_row_actions import AdminRowActionsMixin
    ...
    
    class ExampleAdmin(AdminRowActionsMixin, admin.ModelAdmin):
        ...
    
  4. 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.

Credits

Inspired (and code based on): django-object-actions

Includes parts of jquery-dropdown; credits go to Cory LaViska.

Release files for django-admin-row-actions 0.10.0

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-admin-row-actions 0.10.0
File Size Uploaded
django_admin_row_actions-0.10.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-row-actions 0.10.0
File Interpreter ABI Platform
django_admin_row_actions-0.10.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 24.1 kB

Release files / django_admin_row_actions-0.10.0.tar.gz

Download URL django_admin_row_actions-0.10.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b75e2b40d14f3caa230806432b6e0877c27776f3b13c67a5bacf7db5211e4b2e
BLAKE2b-256 checksum
How to use checksums
c4c47dcee6f800722559be540f62604544cdb6d8d56f0ad8281246b0b9f20089
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.3 Darwin/21.6.0

Release files / django_admin_row_actions-0.10.0-py2.py3-none-any.whl

Download URL django_admin_row_actions-0.10.0-py2.py3-none-any.whl
Size 13.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7ac3a9747727b1186b8c1a7d8067c6a0946d3df2bc3b8618a430b7f03c4630e1
BLAKE2b-256 checksum
How to use checksums
89a7ab92b79c93da700657c5d1c3be594b6d474df307d00fc6f94df10ab4ed85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.3 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

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