Re: [Django] #11385: DateTimeField doesn't accept ISO 8601 formatted date string

72 views
Skip to first unread message

Django

unread,
Feb 28, 2016, 11:49:40 PM2/28/16
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+-------------------------------------
Reporter: jtiai | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: 1.0
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: datetime orm format | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by matthewslaney):

* 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.

Django

unread,
Feb 29, 2016, 7:47:44 AM2/29/16
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+------------------------------------
Reporter: jtiai | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: wontfix
Keywords: datetime orm format | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by claudep):

* 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>

Django

unread,
Apr 25, 2016, 12:34:11 AM4/25/16
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+------------------------------------
Reporter: jtiai | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: wontfix
Keywords: datetime orm format | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by bronger):

* cc: bronger@… (added)


Comment:

Note that this is not yet really reopened. An oversight?

--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:5>

Django

unread,
Apr 25, 2016, 2:00:49 AM4/25/16
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+------------------------------------
Reporter: jtiai | Owner: nobody
Type: New feature | Status: new

Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: datetime orm format | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by charettes):

* status: closed => new
* resolution: wontfix =>


--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:6>

Django

unread,
Sep 6, 2016, 5:43:09 PM9/6/16
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+------------------------------------
Reporter: jtiai | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: datetime orm format | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------

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>

Django

unread,
Apr 12, 2018, 7:40:28 PM4/12/18
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+------------------------------------
Reporter: Jani Tiainen | Owner: nobody

Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: datetime orm format | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by W. Trevor King):

* cc: W. Trevor King (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/11385#comment:8>

Django

unread,
Oct 9, 2019, 6:16:59 AM10/9/19
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+------------------------------------
Reporter: Jani Tiainen | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: datetime orm format | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Claude Paroz):

* 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>

Django

unread,
Jan 6, 2020, 5:39:50 AM1/6/20
to django-...@googlegroups.com
#11385: DateTimeField doesn't accept ISO 8601 formatted date string
-------------------------------------+-------------------------------------
Reporter: Jani Tiainen | Owner: Claude
| Paroz

Type: New feature | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: datetime orm format | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages