diff options
| author | Srinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com> | 2017-07-13 20:25:32 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-07-14 13:27:30 -0400 |
| commit | a3b5df8ed503ea559d2ffaca7ec0c735d98f1a38 (patch) | |
| tree | 3430d666d9322066f49390ce2a54501d485ef39c /django/forms/fields.py | |
| parent | fc6b90bdb7a9531e988245942f79518308616b7b (diff) | |
[1.11.x] Fixed #28387 -- Fixed has_changed() for disabled form fields that subclass it.
Backport of 5debbdfcc84266703191e084914998e38f5f52eb from master
Diffstat (limited to 'django/forms/fields.py')
| -rw-r--r-- | django/forms/fields.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 33ed2882a3..f2b5b77185 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -604,6 +604,8 @@ class FileField(Field): return data def has_changed(self, initial, data): + if self.disabled: + return False if data is None: return False return True @@ -724,6 +726,8 @@ class BooleanField(Field): raise ValidationError(self.error_messages['required'], code='required') def has_changed(self, initial, data): + if self.disabled: + return False # 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) @@ -891,6 +895,8 @@ class MultipleChoiceField(ChoiceField): ) def has_changed(self, initial, data): + if self.disabled: + return False if initial is None: initial = [] if data is None: @@ -1069,6 +1075,8 @@ class MultiValueField(Field): raise NotImplementedError('Subclasses must implement this method.') def has_changed(self, initial, data): + if self.disabled: + return False if initial is None: initial = ['' for x in range(0, len(data))] else: |
