funkybob / django-sniplates

Template snippet libraries for Django
MIT License
57 stars 18 forks source link

Align with Django 'input_type' for date/time/datetime fields #62

Closed flupzor closed 6 years ago

flupzor commented 6 years ago

For DateInput, DateTimeInput and TimeInput Django uses input_type 'text'. Align sniplates with this as well.

Using 'date', 'time' or 'datetime' is problematic because the HTML standard defines specific formatting for these input types. For example type 'date' requires a formatting of to be YYYY-MM-DD to be set in the 'value' attribute of the input element.

However the DateInput, DateTimeInput and TimeInput widgets use DATE_INPUT_FORMATS, DATETIME_INPUT_FORMATS and TIME_INPUT_FORMATS respectively to format the value. And these settings can, and often do, differ from what is required by browser/HTML 5.

schinckel commented 6 years ago

But we are in control of the rendering of the value: we should just be able to make sure that the value that is rendered is ISO8601 formatted.

funkybob commented 6 years ago

Whilst @schinckel is right, this particular set of templates are supposed to mimic the stock Django templates.

flupzor commented 6 years ago

Are the failing tests something I should fix? I don't think this PR introduced the breakage, since I see another Travis build also fails with similar errors.

flupzor commented 6 years ago

FWIW, I don't mind either way. Changing it the input types to 'text' will break certain existing templates which expect this to be there, but is the expected behavior for new users.

funkybob commented 6 years ago

No, you didn't cause the failing tests, but I really would appreciate if you could spend a little time trying to find out why they happen :)

funkybob commented 6 years ago

I've dug into this further, and it seems the problem is a change of attribute name between django 1.9 and 1.10... so I can fix it trivially if I drop support before 1.11.