File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
tests/regressiontests/forms Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -399,6 +399,8 @@ def to_python(self, value):
399
399
# components: date and time.
400
400
if len (value ) != 2 :
401
401
raise ValidationError (self .error_messages ['invalid' ])
402
+ if value [0 ] in validators .EMPTY_VALUES and value [1 ] in validators .EMPTY_VALUES :
403
+ return None
402
404
value = '%s %s' % tuple (value )
403
405
for format in self .input_formats or formats .get_format ('DATETIME_INPUT_FORMATS' ):
404
406
try :
Original file line number Diff line number Diff line change @@ -1310,3 +1310,21 @@ def test_12048(self):
1310
1310
# w2 ought to be independent of w1, since MultiWidget ought
1311
1311
# to make a copy of its sub-widgets when it is copied.
1312
1312
self .assertEqual (w1 .choices , [1 ,2 ,3 ])
1313
+
1314
+ def test_13390 (self ):
1315
+ # See ticket #13390
1316
+ class SplitDateForm (forms .Form ):
1317
+ field = forms .DateTimeField (widget = forms .SplitDateTimeWidget , required = False )
1318
+
1319
+ form = SplitDateForm ({'field' : '' })
1320
+ self .assertTrue (form .is_valid ())
1321
+ form = SplitDateForm ({'field' : ['' , '' ]})
1322
+ self .assertTrue (form .is_valid ())
1323
+
1324
+ class SplitDateRequiredForm (forms .Form ):
1325
+ field = forms .DateTimeField (widget = forms .SplitDateTimeWidget , required = True )
1326
+
1327
+ form = SplitDateRequiredForm ({'field' : '' })
1328
+ self .assertFalse (form .is_valid ())
1329
+ form = SplitDateRequiredForm ({'field' : ['' , '' ]})
1330
+ self .assertFalse (form .is_valid ())
You can’t perform that action at this time.
0 commit comments