#34660 closed New feature (duplicate)

Use RFC3339 format and input type=(date|time|datetime-local) for date/time/datetime form fields

Reported by: Nicolás Stuardo Díaz Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords: html5
Cc: Gabriel Rojas Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django should provide a global setting that makes DateInput, DateTimeInput and TimeInput widgets:

  • Use RFC3339 formats for output even when USE_L10N is available.
  • Render those widgets using their respective HTML5 input types.

as most modern browsers now have proper support for date, time and datetime fields and provide date pickers for each of them. The reasoning to use a setting is to make this change opt-in instead of breaking existing functionality.

#16630 and other tickets proposed the usage of input type="date", time and datetime-local for DateInput, TimeInput and DateTimeInput, respectively. By the time those proposals were made, browser support was lacking and most of them handled as simple text inputs, leaving support to polyfills and libraries. 10 years later, the situation changed.

Along with using HTML5 input types, a specific formatting has to be used to ensure browsers handle them correctly. The spec mandates the use of RFC3339, a type of ISO 8601 format. Currently Django formats date values using localized formats, something that was correct when those fields were rendered as text fields or when the end user wants to use a specific format, but invalid when using date, time or datetime-local. There are several ways to patch this behavior currently such as defining custom locale formats or overriding form initialization and manually set input formats.

Change History (2)

comment:1 by Gabriel Rojas, 19 months ago

Cc: Gabriel Rojas added

comment:2 by Mariusz Felisiak, 19 months ago

Resolution: duplicate
Status: newclosed

Duplicate of #21470 and #33100. This was also discussed on the mailing list.

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