Opened 7 years ago

Last modified 2 months ago

#11385 new New feature

DateTimeField doesn't accept ISO 8601 formatted date string

Reported by: jtiai Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords: datetime orm format
Cc: bronger@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

DateTimeField doesn't accept ISO 8601 formatted date string. Differene is that ISO format allows date and time separator to be capital T letter. (Format being YYYY-MM-DDTHH:MM:SS. Django expects to have only space as a date and time separator.

Change History (6)

comment:1 follow-up: Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

ISO8601 is a good machine format, but not a particularly nice human readable format. Form processing is primarily about human-readable input.

If you disagree, the DateTimeField input formats are configurable (DATETIME_INPUT_FORMATS), so you can add ISO8601 format in your own projects if you want.

comment:2 Changed 6 years ago by kmike

I think the problem can't be resolved with DATETIME_INPUT_FORMATS tweaking.

ISO8601 format allows timezone info: '2010-09-01T19:52:15+04:00'. Such strings can't be parsed with python's strptime because python's strptime doesn't support '%z' format char (http://bugs.python.org/issue6641). So DATETIME_INPUT_FORMATS directive is not helpful for ISO8601 handling.

The solution is probably to use custom form field.

comment:3 in reply to: ↑ 1 Changed 4 months ago by matthewslaney

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

Replying to russellm:

ISO8601 is a good machine format, but not a particularly nice human readable format. Form processing is primarily about human-readable input.

If you disagree, the DateTimeField input formats are configurable (DATETIME_INPUT_FORMATS), so you can add ISO8601 format in your own projects if you want.

Hi Russell,

I understand your reasoning at the time this was closed for not supporting the T separator. However, this is not relevant again because of the way HTML5 provides the new Input Types. By default, using the datetime-local Input Type results in the format of YYYY-MM-DDTHH:MM. It would definitely make it nice to allow for that Input Type default to work properly with DateTimeField.

comment:4 Changed 4 months ago by claudep

  • Component changed from Database layer (models, ORM) to Forms
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to New feature
  • Version changed from 1.0 to master

Reopening, considering comment:3, Python issue 6641 being fixed on Python 3 and the presence of django.utils.formats.ISO_INPUT_FORMATS.

comment:5 Changed 2 months ago by bronger

  • Cc bronger@… added

Note that this is not yet really reopened. An oversight?

comment:6 Changed 2 months ago by charettes

  • Resolution wontfix deleted
  • Status changed from closed to new
Note: See TracTickets for help on using tickets.
Back to Top