Re: [Django] #33731: Updating choices with list methods does not update widget's choices. (was: Updating choices of ChoiceField does not update the underlying widget's choices)

6 views
Skip to first unread message

Django

unread,
May 23, 2022, 12:52:41 AM5/23/22
to django-...@googlegroups.com
#33731: Updating choices with list methods does not update widget's choices.
-------------------------------------+-------------------------------------
Reporter: Stefan-Ionut | Owner: Aman
Tarabuta | Pandey
Type: | Status: closed
Cleanup/optimization |
Component: Forms | Version: 3.2
Severity: Normal | Resolution: wontfix
Keywords: ChoiceField, | Triage Stage:
choices, form | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* type: Bug => Cleanup/optimization
* resolution: => wontfix


Comment:

Thanks for this report, however IMO it's not doable.
[https://docs.djangoproject.com/en/stable/ref/forms/fields/#django.forms.ChoiceField.choices
choices] supports many types and we cannot enforce updating widget's
`choices` when built-in methods are called for `list` or `tuple`, it's a
different layer. I'd recommend to use a callable for `choices` or to
enforce updating `widget.choices` :
{{{
self.fields["my_field"].widget.choices = self.fields["my_field"].choices
}}}

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

Reply all
Reply to author
Forward
0 new messages