summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-05-03 11:52:30 +0000
committerJannis Leidel <jannis@leidel.info>2011-05-03 11:52:30 +0000
commit8ce352c21d9ce4c59fcd259103350772954a6f8e (patch)
treec6efac70aa82b86a3379fef08eed83b385ddf61d
parentf4860448ddad760172b4dde0323140e99d78a55f (diff)
Fixed #13770 -- Extended BooleanField form field to also clean `u'false'` to `False`. Thanks, jordanb and Claude Paroz.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16148 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/forms/fields.py2
-rw-r--r--tests/regressiontests/forms/tests/fields.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index e3299c07aa..a5ea81d4b6 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -605,7 +605,7 @@ class BooleanField(Field):
# 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)
diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
index 59c761c76d..2303b4e9db 100644
--- a/tests/regressiontests/forms/tests/fields.py
+++ b/tests/regressiontests/forms/tests/fields.py
@@ -698,6 +698,8 @@ class FieldsTests(TestCase):
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 #################################################################