#30014: Initialising disabled ModelChoiceField yields 'Select a valid
choice'-error
despite initialised option being valid
-------------------------------------+-------------------------------------
Reporter: thoha | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 2.1
Severity: Normal | Resolution:
Keywords: forms, disabled | Triage Stage:
field, error, to_field_name | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carlton Gibson):
Hi Etienne.
I am sympathetic to your point. Looking at your test-case, it is a little-
strange that it accepts the model instance in the one-case but not in the
other.
The addition Tim offers for the docs is right too: don't give a form data
that it would never normally receive and expect it to work. (Garbage in,
garbage out.)
So the thought about mapping to the `pk` in init seems a possibility. (We
want to allow passing instances, but lets move from that as quickly as
possible.)
The other thought is, yes, don't allow passing instances at all...
The difficulty here is "why is it as it is? & what breaks?" Answering that
definitively is why this is still "Unreviewed" (We have looked at it. 🙂)
How about you put your patch (with test) in a PR on Github? That way the
CI will tell us the "what breaks?" bit.
--
Ticket URL: <https://code.djangoproject.com/ticket/30014#comment:13>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.865d8c33ec17641605522a68c177db9f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.