Skip to content

Detail page: per-object (single-pk) actions missing — only the changelist multi-select actions render (follow-up to #555 / PR #562) #571

@martin-castro-laminr-ai

Description

Symptom

On the detail page of a single object (/admin2/<app>/<model>/<pk>/change/), the action toolbar shows the changelist multi-select actions (the ones declared on ModelAdmin.actions = [...]) but does not show the per-object actions registered via django-object-actions (change_actions = [...]) — the single-pk operations that should appear on the detail page only.

Confirmed on django-admin-react==1.0.1 (latest stable), django-object-actions declared correctly on the ModelAdmin (verified via the legacy /admin/ HTML detail page, which renders them as expected).

Expected

On a detail page, two distinct sets of buttons should be visible:

  1. Per-object actions (change_actions): operations meaningful on the single object being viewed (e.g. "Reprocess", "Approve", "Mark as reviewed"). These are declared on the ModelAdmin via django-object-actions.DjangoObjectActions.change_actions. They take no multi-select — they always operate on the current pk.
  2. Edit / Delete standard admin buttons.

The bulk changelist actions ("Delete selected …", "Disable All Selected …", "Reprocess selected …") should not appear on the detail page, or at minimum should be visually demoted — they're list-page semantics applied to a "selection" of one, which is confusing.

Actual

Detail page renders, in order:

  • All ModelAdmin.actions (bulk operations), worded "selected files" / "selected items".
  • Edit.
  • Delete.

No change_actions (single-pk buttons) appear, even when the ModelAdmin declares them and the REST API exposes them at /api/v1/admin/<app>/<model>/<pk>/change-actions/ (or equivalent).

PR #562 ("detail-page admin action buttons reusing the changelist actions API") shipped the wrong primitive: it surfaces the changelist action endpoint (multi-select, list semantics) on the detail page instead of the single-pk change-action endpoint (django-object-actions).

Probable cause

DetailPage.tsx is wired to the changelist actions endpoint (POST /api/.../actions/) with pks=[currentPk] rather than the change-actions endpoint that surfaces ModelAdmin.change_actions from django-object-actions.

The REST API side appears to already expose change_actions (see #540 / be589ad feat(api): object-level change-page actions (django-object-actions)), so the gap is on the SPA side: it's calling the wrong endpoint.

Suggested fix direction

In DetailPage.tsx, fetch and render change_actions from the per-object endpoint introduced in #540 instead of (or in addition to) the changelist actions. The bulk "selected files" actions should either be removed from the detail page entirely, or rendered only in a clearly separate group ("Apply to this object as a list of 1") for parity with the legacy admin — but per-object actions must take precedence and be present.

Repro

  1. Declare a ModelAdmin with both actions = [bulk_op] and change_actions = ['per_object_op'] via django-object-actions.
  2. Open the SPA detail page for any instance: /admin2/<app>/<model>/<pk>/change/.
  3. Observe: bulk_op button is present; per_object_op button is absent.
  4. Open the same instance in the legacy admin: /admin/<app>/<model>/<pk>/change/.
  5. Observe: per_object_op IS present in legacy, confirming the ModelAdmin declares it and the API surfaces it.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions