1
0
mirror of https://github.com/django/django.git synced 2025-10-30 00:56:09 +00:00

Fixed #24844 -- Corrected has_changed implementation for HStoreField.

Backport of 43b2d88a5b from master
This commit is contained in:
Andrea Grandi
2015-05-24 15:56:48 +01:00
committed by Tim Graham
parent 2aa2b9f291
commit 62c19a21b6
3 changed files with 20 additions and 1 deletions

View File

@@ -34,3 +34,13 @@ class HStoreField(forms.CharField):
for key, val in value.items():
value[key] = six.text_type(val)
return value
def has_changed(self, initial, data):
"""
Return True if data differs from initial.
"""
# For purposes of seeing whether something has changed, None is
# the same as an empty dict, if the data or initial value we get
# is None, replace it w/ {}.
initial_value = self.to_python(initial)
return super(forms.HStoreField, self).has_changed(initial_value, data)