From 1487f16f2d29c7aeaf48117d02a1d7bbeafa3d94 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 9 Oct 2019 12:08:50 +0200 Subject: Fixed #11385 -- Made forms.DateTimeField accept ISO 8601 date inputs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks José Padilla for the initial patch, and Carlton Gibson for the review. --- docs/ref/forms/fields.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'docs/ref/forms') diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index b5854002c0..7b26b29aee 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -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 `. + .. versionchanged:: 3.1 + + Support for ISO 8601 date string parsing (including optional timezone) + was added. + ``DecimalField`` ---------------- -- cgit v1.3