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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.e2109038262772b76117053b4fbc7e30%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to