Skip to main content

Reuse model admin changelist actions on changeform pages

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_admin_changeform_actions-0.6.0.tar.gz (60.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django_admin_changeform_actions-0.6.0.tar.gz.

File metadata

File hashes

Hashes for django_admin_changeform_actions-0.6.0.tar.gz
Algorithm Hash digest
SHA256 41a9d39755928d3831df10583af48d0201e17d67222b13d66b29dd77a147ead9
MD5 047e2136d8f61616e35c95cf4c007655
BLAKE2b-256 093651aebd96af6c8152bb4db602dcf00adbdd405dc721bc0bb983edbc87f3ba

See more details on using hashes here.

File details

Details for the file django_admin_changeform_actions-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_changeform_actions-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27153b729b5bb4f1cdb17e55cf5959e3acbd2bf5539a6aa8e969a3f3980450aa
MD5 4228bf850a2b6e20c78ad1e831cebfbe
BLAKE2b-256 b0cf8e1bebc5344d8d9159c0ca08e88c13c74b7380182efdd3ebc5fad6efc9d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page