| 1 |
=============== |
| 2 |
Field Reference |
| 3 |
=============== |
| 4 |
|
| 5 |
``IsoDateTimeField`` |
| 6 |
~~~~~~~~~~~~~~~~~~~~ |
| 7 |
|
| 8 |
Extends ``django.forms.DateTimeField`` to allow parsing ISO 8601 formated dates, in addition to existing formats |
| 9 |
|
| 10 |
Defines a class level attribute ``ISO_8601`` as constant for the format. |
| 11 |
|
| 12 |
Sets ``input_formats = [ISO_8601]`` — this means that by default ``IsoDateTimeField`` will **only** parse ISO 8601 formated dates. |
| 13 |
|
| 14 |
You may set ``input_formats`` to your list of required formats as per the `DateTimeField Docs`_, using the ``ISO_8601`` class level attribute to specify the ISO 8601 format. |
| 15 |
|
| 16 |
.. code-block:: python |
| 17 |
|
| 18 |
f = IsoDateTimeField() |
| 19 |
f.input_formats = [IsoDateTimeField.ISO_8601] + DateTimeField.input_formats |
| 20 |
|
| 21 |
|
| 22 |
.. _`DateTimeField Docs`: https://docs.djangoproject.com/en/stable/ref/forms/fields/#django.forms.DateTimeField.input_formats |
| 23 |
|