Author: jezdez
Date: 2011-05-03 04:52:30 -0700 (Tue, 03 May 2011)
New Revision: 16148
Modified:
django/trunk/django/forms/fields.py
django/trunk/tests/regressiontests/forms/tests/fields.py
Log:
Fixed #13770 -- Extended BooleanField form field to also clean `u'false'` to
`False`. Thanks, jordanb and Claude Paroz.
Modified: django/trunk/django/forms/fields.py
===================================================================
--- django/trunk/django/forms/fields.py 2011-05-03 11:52:20 UTC (rev 16147)
+++ django/trunk/django/forms/fields.py 2011-05-03 11:52:30 UTC (rev 16148)
@@ -605,7 +605,7 @@
# will submit for False. Also check for '0', since this is what
# RadioSelect will provide. Because bool("True") == bool('1') == True,
# we don't need to handle that explicitly.
- if value in ('False', '0'):
+ if isinstance(value, basestring) and value.lower() in ('false', '0'):
value = False
else:
value = bool(value)
Modified: django/trunk/tests/regressiontests/forms/tests/fields.py
===================================================================
--- django/trunk/tests/regressiontests/forms/tests/fields.py 2011-05-03
11:52:20 UTC (rev 16147)
+++ django/trunk/tests/regressiontests/forms/tests/fields.py 2011-05-03
11:52:30 UTC (rev 16148)
@@ -698,6 +698,8 @@
self.assertEqual(False, f.clean('0'))
self.assertEqual(True, f.clean('Django rocks'))
self.assertEqual(False, f.clean('False'))
+ self.assertEqual(False, f.clean('false'))
+ self.assertEqual(False, f.clean('FaLsE'))
# ChoiceField
#################################################################
--
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.