[Django] #34660: Use RFC3339 format and input type=(date|time|datetime-local) for date/time/datetime form fields

34 views
Skip to first unread message

Django

unread,
Jun 16, 2023, 12:19:46 PM6/16/23
to django-...@googlegroups.com
#34660: Use RFC3339 format and input type=(date|time|datetime-local) for
date/time/datetime form fields
------------------------------------------------+------------------------
Reporter: Nicolás Stuardo Díaz | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: dev
Severity: Normal | Keywords: html5
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34660>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 16, 2023, 12:27:19 PM6/16/23
to django-...@googlegroups.com
#34660: Use RFC3339 format and input type=(date|time|datetime-local) for
date/time/datetime form fields
-------------------------------------+-------------------------------------
Reporter: Nicolás Stuardo | Owner: nobody
Díaz |

Type: New feature | Status: new
Component: Forms | Version: dev
Severity: Normal | Resolution:

Keywords: html5 | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gabriel Rojas):

* cc: Gabriel Rojas (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/34660#comment:1>

Django

unread,
Jun 16, 2023, 12:35:37 PM6/16/23
to django-...@googlegroups.com
#34660: Use RFC3339 format and input type=(date|time|datetime-local) for
date/time/datetime form fields
-------------------------------------+-------------------------------------
Reporter: Nicolás Stuardo | Owner: nobody
Díaz |
Type: New feature | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: duplicate

Keywords: html5 | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #21470 and #33100. This was also [https://groups.google.com/g
/django-developers/c/wp-pnzcB25o/m/D5gEOzPIAQAJ discussed] on the mailing
list.

--
Ticket URL: <https://code.djangoproject.com/ticket/34660#comment:2>

Reply all
Reply to author
Forward
0 new messages