Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #20781 -- Fixed _has_changed regression with MultiValueField

Thanks Tim Graham for the report.
  • Loading branch information...
commit 02b0106d43f6997f02cc6785359f8f7519215d3d 1 parent bb145e2
@claudep claudep authored
View
2  django/forms/fields.py
@@ -1025,7 +1025,7 @@ def _has_changed(self, initial, data):
if not isinstance(initial, list):
initial = self.widget.decompress(initial)
for field, initial, data in zip(self.fields, initial, data):
- if field._has_changed(initial, data):
+ if field._has_changed(field.to_python(initial), data):
return True
return False
View
2  tests/forms_tests/tests/test_extra.py
@@ -391,7 +391,7 @@ def __init__(self, attrs=None):
def decompress(self, value):
if value:
data = value.split(',')
- return [data[0], data[1], datetime.datetime.strptime(data[2], "%Y-%m-%d %H:%M:%S")]
+ return [data[0], list(data[1]), datetime.datetime.strptime(data[2], "%Y-%m-%d %H:%M:%S")]
return [None, None, None]
def format_output(self, rendered_widgets):
View
1  tests/forms_tests/tests/test_fields.py
@@ -1247,6 +1247,7 @@ def test_splitdatetimefield_2(self):
def test_splitdatetimefield_changed(self):
f = SplitDateTimeField(input_date_formats=['%d/%m/%Y'])
+ self.assertFalse(f._has_changed(['11/01/2012', '09:18:15'], ['11/01/2012', '09:18:15']))
self.assertTrue(f._has_changed(datetime.datetime(2008, 5, 6, 12, 40, 00), ['2008-05-06', '12:40:00']))
self.assertFalse(f._has_changed(datetime.datetime(2008, 5, 6, 12, 40, 00), ['06/05/2008', '12:40']))
self.assertTrue(f._has_changed(datetime.datetime(2008, 5, 6, 12, 40, 00), ['06/05/2008', '12:41']))
Please sign in to comment.
Something went wrong with that request. Please try again.