#33805: SelectMultiple in ModelAdminForm display help text when
allow_multiple_selected is False.
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.1
Severity: Normal | Resolution:
Keywords: modeladmin, | Triage Stage: Accepted
AdminForm |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Thanks for the report. As far as I understand correctly, you have a
subclass of `SelectMultiple` with `allow_multiple_selected` set to
`False`, that's quite niche. However, I agree that we should check
`allow_multiple_selected` in both places:
{{{#!diff
diff --git a/django/contrib/admin/options.py
b/django/contrib/admin/options.py
index a25814b5fb..f959a8dc48 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -314,8 +314,12 @@ class
BaseModelAdmin(metaclass=forms.MediaDefiningClass):
kwargs["queryset"] = queryset
form_field = db_field.formfield(**kwargs)
- if isinstance(form_field.widget, SelectMultiple) and not
isinstance(
- form_field.widget, (CheckboxSelectMultiple,
AutocompleteSelectMultiple)
+ if (
+ isinstance(form_field.widget, SelectMultiple)
+ and form_field.widget.allow_multiple_selected
+ and not isinstance(
+ form_field.widget, (CheckboxSelectMultiple,
AutocompleteSelectMultiple)
+ )
):
msg = _(
"Hold down “Control”, or “Command” on a Mac, to select
more than one."
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33805#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018194dca029-efbae4db-f721-4c63-9f5c-60fa9f7412e6-000000%40eu-central-1.amazonses.com.