mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #15982 -- Added DATE_INPUT_FORMATS to forms.DateTimeField default input formats.
This commit is contained in:
parent
0f0abc20be
commit
188b003014
42 changed files with 32 additions and 119 deletions
|
@ -505,16 +505,20 @@ For each field, we describe the default widget used if you don't specify
|
|||
* '2006-10-25'
|
||||
|
||||
If no ``input_formats`` argument is provided, the default input formats are
|
||||
taken from :setting:`DATETIME_INPUT_FORMATS` if :setting:`USE_L10N` is
|
||||
``False``, or from the active locale format ``DATETIME_INPUT_FORMATS`` key
|
||||
if localization is enabled. See also :doc:`format localization
|
||||
</topics/i18n/formatting>`.
|
||||
taken from :setting:`DATETIME_INPUT_FORMATS` and
|
||||
:setting:`DATE_INPUT_FORMATS` if :setting:`USE_L10N` is ``False``, or from
|
||||
the active locale format ``DATETIME_INPUT_FORMATS`` and
|
||||
``DATE_INPUT_FORMATS`` keys if localization is enabled. See also
|
||||
:doc:`format localization </topics/i18n/formatting>`.
|
||||
|
||||
.. versionchanged:: 3.1
|
||||
|
||||
Support for ISO 8601 date string parsing (including optional timezone)
|
||||
was added.
|
||||
|
||||
The fallback on ``DATE_INPUT_FORMATS`` in the default ``input_formats``
|
||||
was added.
|
||||
|
||||
``DecimalField``
|
||||
----------------
|
||||
|
||||
|
|
|
@ -1135,28 +1135,30 @@ Default::
|
|||
'%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'
|
||||
'%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200'
|
||||
'%Y-%m-%d %H:%M', # '2006-10-25 14:30'
|
||||
'%Y-%m-%d', # '2006-10-25'
|
||||
'%m/%d/%Y %H:%M:%S', # '10/25/2006 14:30:59'
|
||||
'%m/%d/%Y %H:%M:%S.%f', # '10/25/2006 14:30:59.000200'
|
||||
'%m/%d/%Y %H:%M', # '10/25/2006 14:30'
|
||||
'%m/%d/%Y', # '10/25/2006'
|
||||
'%m/%d/%y %H:%M:%S', # '10/25/06 14:30:59'
|
||||
'%m/%d/%y %H:%M:%S.%f', # '10/25/06 14:30:59.000200'
|
||||
'%m/%d/%y %H:%M', # '10/25/06 14:30'
|
||||
'%m/%d/%y', # '10/25/06'
|
||||
]
|
||||
|
||||
A list of formats that will be accepted when inputting data on a datetime
|
||||
field. Formats will be tried in order, using the first valid one. Note that
|
||||
these format strings use Python's :ref:`datetime module syntax
|
||||
<strftime-strptime-behavior>`, not the format strings from the :tfilter:`date`
|
||||
template filter.
|
||||
template filter. Date-only formats are not included as datetime fields will
|
||||
automatically try :setting:`DATE_INPUT_FORMATS` in last resort.
|
||||
|
||||
When :setting:`USE_L10N` is ``True``, the locale-dictated format has higher
|
||||
precedence and will be applied instead.
|
||||
|
||||
See also :setting:`DATE_INPUT_FORMATS` and :setting:`TIME_INPUT_FORMATS`.
|
||||
|
||||
.. versionchanged:: 3.1
|
||||
|
||||
In older versions, the default is a list containing also date-only formats.
|
||||
|
||||
.. setting:: DEBUG
|
||||
|
||||
``DEBUG``
|
||||
|
|
|
@ -181,7 +181,9 @@ Forms
|
|||
|
||||
* :class:`django.forms.DateTimeField` now accepts dates in a subset of ISO 8601
|
||||
datetime formats, including optional timezone (e.g. ``2019-10-10T06:47``,
|
||||
``2019-10-10T06:47:23+04:00``, or ``2019-10-10T06:47:23Z``).
|
||||
``2019-10-10T06:47:23+04:00``, or ``2019-10-10T06:47:23Z``). Additionally, it
|
||||
now uses ``DATE_INPUT_FORMATS`` in addition to ``DATETIME_INPUT_FORMATS``
|
||||
when converting a field input to a ``datetime`` value.
|
||||
|
||||
Generic Views
|
||||
~~~~~~~~~~~~~
|
||||
|
@ -401,6 +403,9 @@ Miscellaneous
|
|||
Group Specification, i.e. values between 69 and 99 are mapped to the previous
|
||||
century, and values between 0 and 68 are mapped to the current century.
|
||||
|
||||
* Date-only formats are removed from the default list for
|
||||
:setting:`DATETIME_INPUT_FORMATS`.
|
||||
|
||||
.. _deprecated-features-3.1:
|
||||
|
||||
Features deprecated in 3.1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue