Opened 15 years ago
Closed 10 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: | dev |
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 |
Description
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)
Change History (7)
by , 15 years ago
Attachment: | datetime_time_fractional_seconds.patch added |
---|
comment:1 by , 15 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:6 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
I don't think this is a problem any longer nowadays.
See #9459/[dce278673a409a10c1f74f597035b737bbf6a017]
and #19917 [384c180e414a982a6cc5ccabc675bcfb4fd80988]
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".