Opened 3 years ago

Closed 2 years ago

#33807 closed New feature (wontfix)

Suggestion: Admin actions drop-down with opt-groups

Reported by: Jonas Vacek Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords: admin, actions, drop-down, optgroup
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

The action dropdown inside of a model's list only accepts a flat list of the actions (as seen in actions example here https://docs.djangoproject.com/en/4.0/ref/contrib/admin/actions/#actions-as-modeladmin-methods)

It would be nice to be able to structure this drop-down with opt-groups https://www.w3schools.com/tags/tag_optgroup.asp

As a suggestion, the "format" for this could be similar to the way Choices are made as seen in the example for MEDIA_CHOICES here

https://docs.djangoproject.com/en/4.0/ref/models/fields/#django.db.models.Field.choices

Attachments (1)

Screenshot 2022-06-28 at 09.52.55.png (91.8 KB ) - added by Carlton Gibson 2 years ago.
Screenshot of grouped actions.

Download all attachments as: .zip

Change History (2)

by Carlton Gibson, 2 years ago

Screenshot of grouped actions.

comment:1 by Carlton Gibson, 2 years ago

Resolution: wontfix
Status: newclosed
Type: UncategorizedNew feature

This should already be possible overriding ModelAdmin.get_action_choices() (src)

This returns an iterable to be assigned to the form field's choices, so grouping them works as expected:

https://code.djangoproject.com/raw-attachment/ticket/33807/Screenshot%202022-06-28%20at%2009.52.55.png

Historically, e.g. #19235, requests have centred around not using a select at all, since the number of actions is typically low, so I don't think expanding the documentation here is worthwhile.

Note: See TracTickets for help on using tickets.
Back to Top