Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #20781 -- Fixed _has_changed regression with MultiValueField

Thanks Tim Graham for the report.
  • Loading branch information...
commit 02b0106d43f6997f02cc6785359f8f7519215d3d 1 parent bb145e2
Claude Paroz authored
2  django/forms/fields.py
@@ -1025,7 +1025,7 @@ def _has_changed(self, initial, data):
1025 1025
             if not isinstance(initial, list):
1026 1026
                 initial = self.widget.decompress(initial)
1027 1027
         for field, initial, data in zip(self.fields, initial, data):
1028  
-            if field._has_changed(initial, data):
  1028
+            if field._has_changed(field.to_python(initial), data):
1029 1029
                 return True
1030 1030
         return False
1031 1031
 
2  tests/forms_tests/tests/test_extra.py
@@ -391,7 +391,7 @@ def __init__(self, attrs=None):
391 391
             def decompress(self, value):
392 392
                 if value:
393 393
                     data = value.split(',')
394  
-                    return [data[0], data[1], datetime.datetime.strptime(data[2], "%Y-%m-%d %H:%M:%S")]
  394
+                    return [data[0], list(data[1]), datetime.datetime.strptime(data[2], "%Y-%m-%d %H:%M:%S")]
395 395
                 return [None, None, None]
396 396
 
397 397
             def format_output(self, rendered_widgets):
1  tests/forms_tests/tests/test_fields.py
@@ -1247,6 +1247,7 @@ def test_splitdatetimefield_2(self):
1247 1247
 
1248 1248
     def test_splitdatetimefield_changed(self):
1249 1249
         f = SplitDateTimeField(input_date_formats=['%d/%m/%Y'])
  1250
+        self.assertFalse(f._has_changed(['11/01/2012', '09:18:15'], ['11/01/2012', '09:18:15']))
1250 1251
         self.assertTrue(f._has_changed(datetime.datetime(2008, 5, 6, 12, 40, 00), ['2008-05-06', '12:40:00']))
1251 1252
         self.assertFalse(f._has_changed(datetime.datetime(2008, 5, 6, 12, 40, 00), ['06/05/2008', '12:40']))
1252 1253
         self.assertTrue(f._has_changed(datetime.datetime(2008, 5, 6, 12, 40, 00), ['06/05/2008', '12:41']))

0 notes on commit 02b0106

Please sign in to comment.
Something went wrong with that request. Please try again.