Fixed #20781 -- Fixed _has_changed regression with MultiValueField
Thanks Tim Graham for the report.
This commit is contained in:
parent
bb145e2c47
commit
02b0106d43
|
@ -1025,7 +1025,7 @@ class MultiValueField(Field):
|
|||
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
|
||||
|
||||
|
|
|
@ -391,7 +391,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
|
|||
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):
|
||||
|
|
|
@ -1247,6 +1247,7 @@ class FieldsTests(SimpleTestCase):
|
|||
|
||||
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']))
|
||||
|
|
Loading…
Reference in New Issue