Skip to content

Detail page: per-object action buttons reusing the changelist actions API (single-pk runs) #555

@MartinCastroAlvarez

Description

@MartinCastroAlvarez

Problem

The detail page currently exposes History / Edit / Delete, but no admin-action buttons — so an admin's `actions = […]` is reachable from the changelist (bulk) but not from the detail of a single object. A user looking at one record can't run the same action on just that record without going back to the list, selecting the single row, and dispatching from there.

Expected

The detail page surfaces the model admin's standard `actions` as buttons (alongside History / Edit / Delete), reusing the same actions API the changelist uses — just sending a single pk (the current object) instead of the multi-pk array.

  • Same wire endpoint as the bulk action runner (`POST //actions//`).
  • Same permission gate (`get_actions(request)` re-resolved server-side per action).
  • Same `message_user` / redirect / intermediate-response handling already wired in the changelist runner — so an action that returns an HttpResponse opens it in a new tab here too (the Actions: support intermediate / form-returning admin actions (not just instant runs) #250 minimum).
  • Confirmation modal (`requires_confirmation`) and the single-pk count ("Run X on 1 selected item?") both work.

Out of scope

Acceptance

  • Each action declared in `ModelAdmin.actions` (and permitted for the request) renders as a button on the detail page.
  • Clicking it runs the action endpoint with a one-pk array; the result flow matches the changelist (`message_user`, toast, redirect-in-new-tab on intermediate response).
  • Buttons hidden when the model has no actions or the user has no `change` permission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions