[Django] #25189: DateTimeField cannot validate isoformat() datetime strings.

30 views
Skip to first unread message

Django

unread,
Jul 29, 2015, 4:52:14 AM7/29/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+--------------------
Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------
given:
{{{
from datetime import datetime
dt = datetime.now()
formatted = dt.isoformat()
f = forms.DateTimeField()
f.clean(value=formatted)
}}}
a ValidationError will be raised because the default `sep` for isoformat
is `T` and that format isn't in the default `DATETIME_INPUT_FORMATS`.

I came across this while looking to serialize a `form.cleaned_data`
dictionary to JSON using the internal `DjangoJSONEncoder` - to work around
it in what is ostensibly a re-usable app, I had to subclass the
`DjangoJSONEncoder` to handle datetimes before going to the `super()`

I have a unit test and patch available, if accepted.

--
Ticket URL: <https://code.djangoproject.com/ticket/25189>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 29, 2015, 3:23:41 PM7/29/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+------------------------------------

Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

I can't immediately think of anything that could go wrong.

--
Ticket URL: <https://code.djangoproject.com/ticket/25189#comment:1>

Django

unread,
Jul 30, 2015, 3:55:04 AM7/30/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+------------------------------------

Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by kezabelle):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/25189#comment:2>

Django

unread,
Jul 30, 2015, 12:57:14 PM7/30/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+------------------------------------

Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* needs_docs: 0 => 1


Comment:

As noted on the pull request, it seems this would only work with `USE_L18N
= False`. Should we add it all locale's `formats.py`? I'm not sure. At
least documentation is needed.

--
Ticket URL: <https://code.djangoproject.com/ticket/25189#comment:3>

Django

unread,
Jul 31, 2015, 4:07:09 AM7/31/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+------------------------------------

Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by kezabelle):

Given the need to touch at least 40 locales files, and presumably write at
least N further tests to cover those, I'm inclined to say kick the ticket
to DDN and see if it ever gets at least +0, rather than spend further time
refining it.

--
Ticket URL: <https://code.djangoproject.com/ticket/25189#comment:4>

Django

unread,
Jul 31, 2015, 8:41:07 AM7/31/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+------------------------------------

Reporter: kezabelle | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by timgraham):

We removed the "Design Decision Needed" triage stage since that's where
tickets went to die. If you want to write to the mailing list to get
feedback on this, please do that. Otherwise, it's probably better to close
the ticket rather than leave it open without a clear path to resolution.

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

Django

unread,
Aug 4, 2015, 2:03:17 PM8/4/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+------------------------------------
Reporter: kezabelle | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

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


Comment:

Marking as "won't fix" until someone is motivated to write to the mailing
list and argue for this change or propose an alternate solution.

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

Django

unread,
Sep 2, 2015, 9:30:01 AM9/2/15
to django-...@googlegroups.com
#25189: DateTimeField cannot validate isoformat() datetime strings.
-----------------------------+------------------------------------
Reporter: kezabelle | Owner: nobody
Type: New feature | Status: closed
Component: Forms | Version: master

Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------

Comment (by timgraham):

See also #11385 and #23448.

--
Ticket URL: <https://code.djangoproject.com/ticket/25189#comment:7>

Reply all
Reply to author
Forward
0 new messages