#11303: changed_data wrong work with BooleanField
-------------------------------+--------------------------------------------
Reporter: oduvan | Owner: nobody
Status: new | Milestone:
Component: Forms | Version: 1.1-beta-1
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------+--------------------------------------------
Comment (by margieroginski):
I just want to mention that I have also encountered this bug and I don't
think it is just a corner case in the admin as described by Russelm. I
believe this is a general bug with the case where a BooleanField has
show_hidden_initial set to True. When the HiddenInput widget for this
field is rendered based on POST data and the POST data contains no data
for the field (which occurs when the check box is unchecked), the
HiddenInput is rendered with the string "False" as its value. In this
case. when CheckboxInput's _has_changed() method is run to compare initial
with data, intial is set to "False" and data is set to False (the python
False value, not the string "False"). In the released code _has_changed()
looks like this:
{{{
return bool(initial) != bool(data)
}}}
With initial set to "False" and data set to python's False value, this
returns True, which is incorrect. This is a situation where the user has
not changed the value of the field, yet due to the rendering of the
HiddenInput with the string "False", has_changed() will return True.
The attached patch does seem to work for me (the one called
"show_hidden_initial_boolean.diff").
Margie
--
Ticket URL: <http://code.djangoproject.com/ticket/11303#comment:8>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.