brutasse/django-floppyforms — Issue #27: Date formatting of input type=date value attribute should always be rfc3339
Author: poswald
Created: 2012-01-15 08:48:04+00:00
State: open

Certain cases with regards to how floppyforms handles date/time types is broken. For example, this code (which is arguably wrong but works in django):

date = forms.DateField(label=_('Date'), initial=lambda: datetime.now())

Here we have a form that is a DateField but the underlying model is a DateTime. This will output an input type like:

.. which is different than the django output as well as immediately invalid under html5. Two issues conspire to make it difficult to resolve:

* Most browsers have poor or broken implementations of date/time pickers and no way to enable disable them other than setting input type="text"
* The formats [allowed by the HTML specification](http://dev.w3.org/html5/markup/input.date.html#input.date.attrs.value) for the value parameter [are very restrictive](http://tools.ietf.org/html/rfc3339) and not compatible with localization.

I [brought this up](http://groups.google.com/group/django-developers/browse_thread/thread/0c435fde3ab517fc) in the django-devlopers group but it affects this project as well. It is possible to have a date input type with a value that doesn't match the format (try setting the default of a Date form field that has a datetime object in the model) which will be instantly flagged as invalid by the browser.

* Technically, localization should be ignored and output of dates should always be rfc3339 full-date types. I am not sure if this is suitable.
* It would be nice to be able to switch certain html5 features on and off on a per-request basis.

I am not sure how much effort is going to go into this project now that django 1.4 is doing something similar but I figured I'd get it documented here.