Opened 2 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)
Change History (2)
by , 2 years ago
Attachment: | Screenshot 2022-06-28 at 09.52.55.png added |
---|
comment:1 by , 2 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Type: | Uncategorized → New 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:
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.
Screenshot of grouped actions.