#30014: Initialising disabled ModelChoiceField yields 'Select a valid 
despite initialised option being valid
               Reporter:  thoha      |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Forms      |        Version:  1.11
               Severity:  Normal     |       Keywords:  forms, disabled
           Triage Stage:             |  field, error
  Unreviewed                         |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
 I have a form with a ModelChoiceField that gets initialised to a specific
 value using get_initial in that form's View. This value is a valid choice
 for that Model. I don't want the user to be able to change the option on
 the form, but it needs to be displayed nonetheless.

 When I set disabled=True on that field in forms.py, submitting the form
 yields the following error:

 <ul class="errorlist"><li>fieldname<ul class="errorlist"><li>Select a
 valid choice. That choice is not one of the available

 Firstly, I would like to comment on the general quality of the error
 message, as it is not very useful: It does not return ''which'' choice it
 considers invalid. Including this information would make the message much
 more informative, and would avoid sending people on a wild goose chase to
 discover what the message could possibly mean.

 Secondly, if a field is disabled but does contain a valid choice,
 validating the form should work and not trigger an error.

 This is probably related to the bugfix for this bug:

Ticket URL: <https://code.djangoproject.com/ticket/30014>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to