#32013: Field choice attribute returns different objects in forms.
---------------------------+--------------------------------------
Reporter: Jaap Roes | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Changes (by Jaap Roes):
* status: closed => new
* resolution: invalid =>
Comment:
I'm left wondering if other places that manipulate `field.choices` will
start breaking in unexpected ways.
There's several instances of things like:
{{{
form.fields["category"].choices = [(pk, label) for pk, label in
form.fields["category"].choices if pk == line.get_category().pk]
}}}
and
{{{
self.fields["realm"].choices = [(k, v) for (k, v) in
self.fields["realm"].choices if str(k) != str(self.exclude.pk)]
}}}
or
{{{
self.fields["matter"].choices += [(self.data["matter"],
str(Matter.objects.get(pk=self.data["matter"], realm=self.realm)),)]
}}}
Our tests don't complain, but that might just be because we're not
covering/asserting deep enough. Can you confirm this code (and other code
that manipulates / works with choices) will remain functional? Or should
we audit the entire codebase to see this new `ModelChoiceIteratorValue`
will break stuff?
P.S. I'm reopening this issue so a PR that adds some clarification to the
docs/release notes can target this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/32013#comment:4>
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/063.4dde4f235a12f8994835043d8cdacd1f%40djangoproject.com.