[Django] #33807: Suggestion: Admin actions drop-down with opt-groups

14 views
Skip to first unread message

Django

unread,
Jun 24, 2022, 8:41:39 AM6/24/22
to django-...@googlegroups.com
#33807: Suggestion: Admin actions drop-down with opt-groups
-------------------------------------+-------------------------------------
Reporter: Jonas | Owner: nobody
Vacek |
Type: | Status: new
Uncategorized |
Component: | Version: dev
contrib.admin | Keywords: admin, actions,
Severity: Normal | drop-down, optgroup
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/33807>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 28, 2022, 4:14:34 AM6/28/22
to django-...@googlegroups.com
#33807: Suggestion: Admin actions drop-down with opt-groups
-------------------------------------+-------------------------------------
Reporter: Jonas Vacek | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: dev
Severity: Normal | Resolution:
Keywords: admin, actions, | Triage Stage:
drop-down, optgroup | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* Attachment "Screenshot 2022-06-28 at 09.52.55.png" added.

Screenshot of grouped actions.

Django

unread,
Jun 28, 2022, 4:18:42 AM6/28/22
to django-...@googlegroups.com
#33807: Suggestion: Admin actions drop-down with opt-groups
-------------------------------------+-------------------------------------
Reporter: Jonas Vacek | Owner: nobody
Type: New feature | Status: closed
Component: contrib.admin | Version: dev
Severity: Normal | Resolution: wontfix

Keywords: admin, actions, | Triage Stage:
drop-down, optgroup | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* type: Uncategorized => New feature
* resolution: => wontfix


Comment:

This should already be possible overriding
`ModelAdmin.get_action_choices()`
([https://github.com/django/django/blob/bff5c114be2b7a3fbc735c232abcc6ad4db89a9d/django/contrib/admin/options.py#L1022
src])

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

[[Image(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.

--
Ticket URL: <https://code.djangoproject.com/ticket/33807#comment:1>

Reply all
Reply to author
Forward
0 new messages