#30014: Initialising disabled ModelChoiceField yields 'Select a valid 
choice'-error
despite initialised option being valid
-------------------------------------+-------------------------------------
     Reporter:  thoha                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Forms                |                  Version:  1.11
     Severity:  Normal               |               Resolution:  needsinfo
     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
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => needsinfo


Comment:

 Can you reduce this to a minimal example?

 As far as I can see the underlying behaviour between `disabled` and
 `initial` is correct:

 {{{
 >>> from django import forms
 >>>
 >>> class AForm(forms.Form):
 ...     c = forms.ChoiceField(choices=(("a","A"), ("b", "B")),
 disabled=True)
 ...
 >>> a_form = AForm(data={}, initial={"c":"a"})
 >>> a_form.is_bound
 True
 >>> a_form.is_valid()
 True
 >>> a_form.errors
 {}
 >>> a_form.cleaned_data
 {'c': 'a'}
 }}}

 Thus there must be something more particular about your case.

 Happy to review if we can pin that down.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30014#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 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.8d3376c9833640298f6c44047b755ed9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to