mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #11385 -- Made forms.DateTimeField accept ISO 8601 date inputs.
Thanks José Padilla for the initial patch, and Carlton Gibson for the review.
This commit is contained in:
committed by
Mariusz Felisiak
parent
b23fb2c819
commit
1487f16f2d
@@ -490,7 +490,19 @@ For each field, we describe the default widget used if you don't specify
|
||||
.. attribute:: input_formats
|
||||
|
||||
A list of formats used to attempt to convert a string to a valid
|
||||
``datetime.datetime`` object.
|
||||
``datetime.datetime`` object, in addition to ISO 8601 formats.
|
||||
|
||||
The field always accepts strings in ISO 8601 formatted dates or similar
|
||||
recognized by :func:`~django.utils.dateparse.parse_datetime`. Some examples
|
||||
are::
|
||||
|
||||
* '2006-10-25 14:30:59'
|
||||
* '2006-10-25T14:30:59'
|
||||
* '2006-10-25 14:30'
|
||||
* '2006-10-25T14:30'
|
||||
* '2006-10-25T14:30Z'
|
||||
* '2006-10-25T14:30+02:00'
|
||||
* '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
|
||||
@@ -498,6 +510,11 @@ For each field, we describe the default widget used if you don't specify
|
||||
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.
|
||||
|
||||
``DecimalField``
|
||||
----------------
|
||||
|
||||
|
||||
@@ -179,6 +179,10 @@ Forms
|
||||
to access model instances. See :ref:`iterating-relationship-choices` for
|
||||
details.
|
||||
|
||||
* :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``).
|
||||
|
||||
Generic Views
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user