#23580: forms.fields.NullBooleanField does not honor required=True
-------------------------------+--------------------------------------
     Reporter:  jdufresne      |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  closed
    Component:  Forms          |                  Version:  master
     Severity:  Normal         |               Resolution:  invalid
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by jdufresne):

 > think that your use case is fulfilled by something like:
 >
 > `forms.ChoiceField(widget=forms.RadioSelect, choices=((1, 'Yes'), (0,
 'No')), required=True)`

 One of the issues with this, it evaluates to the string `'1'` and `'0'`
 (or `'True'` and `'False'`) and not the values: `True`, `False`, `None` as
 the `NullBooleanField` does. I think that is the major downside here.

 So in the end, a custom field and widget is required by the application
 writer for something that seems very simple on the surface. That is, a
 boolean form field that does not default to `False` and must be answered
 either `True`/`False`.

 Obviously one can always add this into their own project -- and maybe my
 proposal is the incorrect approach -- but I still think it would be nice
 to have something to accomplish this built-in.

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

Reply via email to