diff --git a/django/forms/fields.py b/django/forms/fields.py
index 8d4fbc4..71129c8 100644
a
|
b
|
class DateTimeField(Field):
|
376 | 376 | Python datetime.datetime object. |
377 | 377 | """ |
378 | 378 | super(DateTimeField, self).clean(value) |
379 | | if value in EMPTY_VALUES: |
380 | | return None |
381 | | if isinstance(value, datetime.datetime): |
382 | | return value |
383 | | if isinstance(value, datetime.date): |
384 | | return datetime.datetime(value.year, value.month, value.day) |
385 | 379 | if isinstance(value, list): |
386 | 380 | # Input comes from a SplitDateTimeWidget, for example. So, it's two |
387 | 381 | # components: date and time. |
388 | 382 | if len(value) != 2: |
389 | 383 | raise ValidationError(self.error_messages['invalid']) |
| 384 | if value[0] in EMPTY_VALUES and value[1] in EMPTY_VALUES: |
| 385 | return None |
390 | 386 | value = '%s %s' % tuple(value) |
| 387 | elif value in EMPTY_VALUES: |
| 388 | return None |
| 389 | if isinstance(value, datetime.datetime): |
| 390 | return value |
| 391 | if isinstance(value, datetime.date): |
| 392 | return datetime.datetime(value.year, value.month, value.day) |
391 | 393 | for format in self.input_formats: |
392 | 394 | try: |
393 | 395 | return datetime.datetime(*time.strptime(value, format)[:6]) |
diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py
index 48da0f9..be091e0 100644
a
|
b
|
ValidationError: [u'Enter a valid date/time.']
|
640 | 640 | >>> f.clean('') |
641 | 641 | >>> repr(f.clean('')) |
642 | 642 | 'None' |
| 643 | >>> f.clean(['', '']) |
| 644 | >>> repr(f.clean(['', ''])) |
| 645 | 'None' |
| 646 | >>> f.clean([None, None]) |
| 647 | >>> repr(f.clean([None, None])) |
| 648 | 'None' |
| 649 | >>> f.clean(['', None]) |
| 650 | >>> repr(f.clean(['', None])) |
| 651 | 'None' |
| 652 | >>> f.clean([None, '']) |
| 653 | >>> repr(f.clean([None, ''])) |
| 654 | 'None' |
643 | 655 | |
644 | 656 | # RegexField ################################################################## |
645 | 657 | |