summaryrefslogtreecommitdiff
path: root/django/forms/fields.py
diff options
context:
space:
mode:
authorDavid Sanders <dsanders11@ucsbalum.com>2016-04-24 12:06:30 -0700
committerSimon Charette <charettes@users.noreply.github.com>2016-04-24 15:06:30 -0400
commit218175b09d244b9c7c84c2f2d5f478297251bbe9 (patch)
tree688f90b3127892ec63fa8f11b5bbcb753f267814 /django/forms/fields.py
parent188883048e2bbd25016ad2bd9b5b60abdefebe73 (diff)
Fixed #26534 -- Fixed boolean form fields has_changed() with hidden input.
Diffstat (limited to 'django/forms/fields.py')
-rw-r--r--django/forms/fields.py17
1 files changed, 3 insertions, 14 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index f3f8756e39..c50cd164ed 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -720,12 +720,9 @@ class BooleanField(Field):
raise ValidationError(self.error_messages['required'], code='required')
def has_changed(self, initial, data):
- # Sometimes data or initial could be None or '' which should be the
- # same thing as False.
- if initial == 'False':
- # show_hidden_initial may have transformed False to 'False'
- initial = False
- return bool(initial) != bool(data)
+ # Sometimes data or initial may be a string equivalent of a boolean
+ # so we should run it through to_python first to get a boolean value
+ return self.to_python(initial) != self.to_python(data)
class NullBooleanField(BooleanField):
@@ -754,14 +751,6 @@ class NullBooleanField(BooleanField):
def validate(self, value):
pass
- def has_changed(self, initial, data):
- # None (unknown) and False (No) are not the same
- if initial is not None:
- initial = bool(initial)
- if data is not None:
- data = bool(data)
- return initial != data
-
class CallableChoiceIterator(object):
def __init__(self, choices_func):