#35126: forms.NullBooleanField's validation logic is surprising
------------------------------+--------------------------------------
     Reporter:  Jeremy Lainé  |                    Owner:  Gaurav sah
         Type:  Bug           |                   Status:  closed
    Component:  Forms         |                  Version:  5.0
     Severity:  Normal        |               Resolution:  invalid
     Keywords:                |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+--------------------------------------

Comment (by Jeremy Lainé):

 I'm a bit surprised by this answer, it seems somewhat besides the point.
 I'm not arguing you cannot use other widgets, I'm saying the default
 widget alters the validation behaviour in an unexpected fashion.

 I would expect NullBooleanField to behave exactly like BooleanField for
 values which normalise to True / False, and validate other values to None.
 This is exactly what NullBooleanField.to_python expresses too. However
 this is not the case out of the box: "0" and "1" get validated to None
 because of what looks like an oversight in NullBooleanWidget.

 This was especially surprising in my use case where I don't even use
 widgets at all, and purely use forms to validate data.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35126#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/0107018d1eea6873-a151e554-42a0-487c-b0a9-1360c0cf0d3f-000000%40eu-central-1.amazonses.com.

Reply via email to