Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #13770 -- Extended BooleanField form field to also clean `u'fal…

…se'` to `False`. Thanks, jordanb and Claude Paroz.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16148 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8ce352c21d9ce4c59fcd259103350772954a6f8e 1 parent f486044
@jezdez jezdez authored
View
2  django/forms/fields.py
@@ -605,7 +605,7 @@ def to_python(self, value):
# 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)
View
2  tests/regressiontests/forms/tests/fields.py
@@ -698,6 +698,8 @@ def test_booleanfield_2(self):
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 #################################################################
Please sign in to comment.
Something went wrong with that request. Please try again.