* ui_ux: => 0
* type: => Uncategorized
* severity: => Normal
* easy: => 0
Comment:
Replying to [comment:1 russellm]:
> ISO8601 is a good machine format, but not a particularly nice human
readable format. Form processing is primarily about human-readable input.
>
> If you disagree, the DateTimeField input formats are configurable
(DATETIME_INPUT_FORMATS), so you can add ISO8601 format in your own
projects if you want.
Hi Russell,
I understand your reasoning at the time this was closed for not supporting
the T separator. However, this is not relevant again because of the way
HTML5 provides the new Input Types. By default, using the datetime-local
Input Type results in the format of YYYY-MM-DDTHH:MM. It would definitely
make it nice to allow for that Input Type default to work properly with
DateTimeField.
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => New feature
* version: 1.0 => master
* component: Database layer (models, ORM) => Forms
* stage: Unreviewed => Accepted
Comment:
Reopening, considering comment:3, Python issue 6641 being fixed on Python
3 and the presence of `django.utils.formats.ISO_INPUT_FORMATS`.
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:4>
* cc: bronger@… (added)
Comment:
Note that this is not yet really reopened. An oversight?
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:5>
* status: closed => new
* resolution: wontfix =>
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:6>
Comment (by julen):
As kmike mentioned above, customizing the form field with an
`input_formats` containing the timezone marker `%z` doesn't help — at
least on Python 2.7. For anyone hitting this, I worked around it by using
a custom form field and overriding the `strptime` method:
{{{
from django.utils.dateparse import parse_datetime
from django.utils.encoding import force_str
class ISODateTimeField(forms.DateTimeField):
def strptime(self, value, format):
return parse_datetime(force_str(value))
}}}
I use Django's own `parse_datetime` utility. Note this is limited to ISO
datetimes, and effectively any `input_formats` are omitted.
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:7>
* cc: W. Trevor King (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:8>
* has_patch: 0 => 1
Comment:
Interest for this is revived by the HTML5 `<input type="datetime-local">`
which is sending input formatted with ISO 8601.
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
/datetime-local
* https://djangotricks.blogspot.com/2019/10/working-with-dates-and-times-
in-forms.html
[https://github.com/django/django/pull/11893 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"1487f16f2d29c7aeaf48117d02a1d7bbeafa3d94" 1487f16f]:
{{{
#!CommitTicketReference repository=""
revision="1487f16f2d29c7aeaf48117d02a1d7bbeafa3d94"
Fixed #11385 -- Made forms.DateTimeField accept ISO 8601 date inputs.
Thanks José Padilla for the initial patch, and Carlton Gibson for the
review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:11>