summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/fields.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index afbf6146b0..b582659099 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -594,7 +594,18 @@ class NullBooleanField(BooleanField):
widget = NullBooleanSelect
def clean(self, value):
- return {True: True, False: False}.get(value, None)
+ """
+ Explicitly checks for the string 'True' and 'False', which is what a
+ hidden field will submit for True and False. Unlike the
+ Booleanfield we also need to check for True, because we are not using
+ the bool() function
+ """
+ if value in (True, 'True'):
+ return True
+ elif value in (False, 'False'):
+ return False
+ else:
+ return None
class ChoiceField(Field):
widget = Select