Opened 5 years ago

Closed 5 weeks 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

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)

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

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by mattbennett

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by mk

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 4 years ago by mattmcc

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 5 weeks ago by claudep

  • Resolution set to duplicate
  • Status changed from new to closed

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