Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25189 closed New feature (wontfix)

DateTimeField cannot validate isoformat() datetime strings.

Reported by: Keryn Knight Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: django@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (7)

comment:1 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

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

comment:2 by Keryn Knight, 9 years ago

Has patch: set

comment:3 by Tim Graham, 9 years ago

Needs documentation: set

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.

comment:4 by Keryn Knight, 9 years ago

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.

comment:5 by Tim Graham, 9 years ago

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.

comment:6 by Tim Graham, 9 years ago

Resolution: wontfix
Status: newclosed

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.

comment:7 by Tim Graham, 9 years ago

See also #11385 and #23448.

Note: See TracTickets for help on using tickets.
Back to Top