Opened 11 years ago
Closed 11 years ago
#21470 closed New feature (wontfix)
Make DateInput and DateTimeInput render as a html5 field type="date" and type="datetime"
Reported by: | Troy Grosfield | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.6 |
Severity: | Normal | Keywords: | datetime, date, widgets, inputs |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
One of my favorite changes to django 1.6 was making all the form inputs render to html5 types:
The default widgets for EmailField, URLField, IntegerField, FloatField and DecimalField use the new type attributes available in HTML5 (type='email', type='url', type='number'). Note that due to erratic support of the number input type with localized numbers in current browsers, Django only uses it when numeric fields are not localized.
So the big question here is why was the date and datetime fields left out if they all just fall back to rendering as text inputs anyway?
- http://www.w3.org/TR/html-markup/input.date.html
- http://www.w3.org/TR/html-markup/input.datetime.html
The untested change I think is simply:
class DateInput(DateTimeBaseInput): format_key = 'DATE_INPUT_FORMATS' input_type = 'date'
and
class DateTimeInput(DateTimeBaseInput): format_key = 'DATETIME_INPUT_FORMATS' input_type = 'datetime'
Change History (3)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
I believe this was intentionally omitted. Have you read the discussion on the ticket?
comment:3 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I figured there was a reason for it, but I didn't see the discussion on the ticket for it. Thanks for the heads up timo.
Created the pull request for this change: