Skip to content

cb109/django-admin-changeform-actions

Repository files navigation

django-admin-changeform-actions

Run pytest Run tox

Replicates the admin actions dropdown (available on a model's changelist page) on each model instance's changeform page.

Instead of targetting a selection the action will target the current model instance only.

Note: Once #12090 makes its way into Django admin, this package will hopefully become obsolete!

Installation

Install the package:

pip install django-admin-changeform-actions

Modify your Django project like:

# settings.py

INSTALLED_APPS = [
  "changeform_actions",  # Must be placed before Django's admin app!
  ...
  "django.contrib.admin",
]
# urls.py

urlpatterns = [
  path("", include("changeform_actions.urls"))
]
# admin.py

from changeform_actions import ChangeFormActionsMixin

class MyModelAdmin(ChangeFormActionsMixin, admin.ModelAdmin):
    actions = [...]

Django Settings

# Whether to display an `Action: <name>` success message after running
# an action. Disable this if you want to display no message or a custom
# message, e.g. as part of each action.
CHANGEFORM_ACTIONS_ENABLE_DEFAULT_MESSAGE: bool = True

# Enable this to preselect the last action in the dropdown, which is
# helpful to repeatedly run the same action several times.
CHANGEFORM_ACTIONS_REMEMBER_LAST_ACTION: bool = False

Development Setup

This project uses uv to handle python versions and dependencies.

uv sync

To do a new release, bump the version in pyproject.toml, then:

uv build
uv publish

Tests

uv run pytest

Run test matrix of different python versions VS different django versions:

uv run tox

About

🔽 Admin actions dropdown on model changeform pages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors