Opened 9 years ago

Closed 4 years ago

#12139 closed New feature (duplicate)

forms.fields.DateTimeField and TimeField so not accept stringified datetimes

Reported by: mattbennett Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords: datetime, forms, datetimefield, timefield
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no


When you stringify a datetime.datetime or datetime.time object, it includes fractional seconds e.g. '2009-11-03 12:21:10.800641'. The default input formats for DateTimeField and TimeField do not expect the fractional seconds part.

This is irritating when using a ModelForm and populating directly without preprocessing the datetimes, for example in a REST API where the form data is generated automatically.

Attachments (1)

datetime_time_fractional_seconds.patch (1.9 KB) - added by mattbennett 9 years ago.

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by mattbennett

comment:1 Changed 9 years ago by Russell Keith-Magee

Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Matthias Kestenholz

This patch not only needs tests, but also other improvements. It will fall on the face with dates f.e. in german format. The stupid check for '.' in the string representation will not do the right thing with "03.11.2009 12:21:10".

comment:3 Changed 8 years ago by Matt McClanahan

Severity: Normal
Type: New feature

comment:4 Changed 7 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 7 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 4 years ago by Claude Paroz

Resolution: duplicate
Status: newclosed

I don't think this is a problem any longer nowadays.
See #9459/[dce278673a409a10c1f74f597035b737bbf6a017]
and #19917 [384c180e414a982a6cc5ccabc675bcfb4fd80988]

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