1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #15982 -- Added DATE_INPUT_FORMATS to forms.DateTimeField default input formats.

This commit is contained in:
Claude Paroz
2020-01-04 11:44:11 +01:00
committed by Mariusz Felisiak
parent 0f0abc20be
commit 188b003014
42 changed files with 32 additions and 119 deletions

View File

@@ -435,9 +435,15 @@ class TimeField(BaseTemporalField):
return datetime.datetime.strptime(value, format).time()
class DateTimeFormatsIterator:
def __iter__(self):
yield from formats.get_format('DATETIME_INPUT_FORMATS')
yield from formats.get_format('DATE_INPUT_FORMATS')
class DateTimeField(BaseTemporalField):
widget = DateTimeInput
input_formats = formats.get_format_lazy('DATETIME_INPUT_FORMATS')
input_formats = DateTimeFormatsIterator()
default_error_messages = {
'invalid': _('Enter a valid date/time.'),
}