=== modified file 'django/forms/fields.py'
|
|
|
397 | 397 | # components: date and time. |
398 | 398 | if len(value) != 2: |
399 | 399 | raise ValidationError(self.error_messages['invalid']) |
| 400 | if value[0] in validators.EMPTY_VALUES and value[1] in validators.EMPTY_VALUES: |
| 401 | return None |
400 | 402 | value = '%s %s' % tuple(value) |
401 | 403 | for format in self.input_formats or formats.get_format('DATETIME_INPUT_FORMATS'): |
402 | 404 | try: |
=== modified file 'tests/regressiontests/forms/widgets.py'
|
|
|
1309 | 1309 | # w2 ought to be independent of w1, since MultiWidget ought |
1310 | 1310 | # to make a copy of its sub-widgets when it is copied. |
1311 | 1311 | self.assertEqual(w1.choices, [1,2,3]) |
| 1312 | |
| 1313 | def test_13390(self): |
| 1314 | # See ticket #13390 |
| 1315 | class SplitDateForm(forms.Form): |
| 1316 | field = forms.DateTimeField(widget=forms.SplitDateTimeWidget, required=False) |
| 1317 | |
| 1318 | form = SplitDateForm({'field': ''}) |
| 1319 | self.assertTrue(form.is_valid()) |
| 1320 | form = SplitDateForm({'field': ['', '']}) |
| 1321 | self.assertTrue(form.is_valid()) |
| 1322 | |
| 1323 | class SplitDateRequiredForm(forms.Form): |
| 1324 | field = forms.DateTimeField(widget=forms.SplitDateTimeWidget, required=True) |
| 1325 | |
| 1326 | form = SplitDateRequiredForm({'field': ''}) |
| 1327 | self.assertFalse(form.is_valid()) |
| 1328 | form = SplitDateRequiredForm({'field': ['', '']}) |
| 1329 | self.assertFalse(form.is_valid()) |