#16630: Support for HTML5 input types

286 views
Skip to first unread message

Jonas H.

unread,
Dec 27, 2011, 11:15:19 AM12/27/11
to django-developers
This patch has been around for while now. I just updated the patch so it
applies cleanly against rev 17281.

So, can we get this patch into trunk or is something missing?

Jonas

--
http://jonas.lophus.org | http://django-mongodb.org

Want to become a Django MongoDB Engine/Django-nonrel core developer?
Get in touch: django-non...@googlegroups.com

Aymeric Augustin

unread,
Dec 27, 2011, 11:35:52 AM12/27/11
to django-d...@googlegroups.com
On 27 déc. 2011, at 17:15, Jonas H. wrote:

> This patch has been around for while now. I just updated the patch so it applies cleanly against rev 17281.
>
> So, can we get this patch into trunk or is something missing?

Hi Jonas,

The patch looks pretty good, but it needs documentation:
- in the widgets reference;
- in the release notes, under backwards-incompatible changes.

Best regards,

--
Aymeric Augustin.

poswald

unread,
Dec 27, 2011, 11:15:49 PM12/27/11
to Django developers
I have a concern regarding this.. A few times I have tried to
integrate django-floppyforms which takes a similar approach to what
the html5 widgets offer (input types are specified by default) and it
often causes pain. The reason is that while browsers say they support
html5 input types sometimes that support is lacking or very badly
implemented. As an example, if you say <input type="date"
value="2011-12-28"> the only officially supported date format is an
RFC-3339 'full-date' format (YYYY-MM-DD) according to the spec:

http://dev.w3.org/html5/markup/input.date.html#input.date.attrs.value
http://tools.ietf.org/html/rfc3339

This means that you cannot have any other format of date string in
that form field.

Now, this ticket 16630 doesn't change the date field specifically but
it does change the number field. (Is there a similar ticket for
changing the date field?) I've run into a similar problem with the
type='number' that this ticket does change. The problem I ran into was
that forms cannot easily use the THOUSANDS_SEPARATOR because it is not
a valid number. It has to be a 'float' to be valid. This means
technically you need to use the text widget for that.

http://dev.w3.org/html5/markup/datatypes.html#common.data.float

So by my thinking this patch (and by extension the thinking of
browsers and the w3) is non-backwards compatible with the way that
django formats numbers when USE_THOUSANDS_SEPARATOR is True or when
localization is turned on.

https://docs.djangoproject.com/en/dev/ref/settings/#use-thousand-separator

Maybe there is something I'm missing here? I just want to flag this as
a concern and make sure that developers know what they are getting
into by enabling that. I would be for this being the default if it
could be disabled. That way, I can use modernizr.js and turn only
certain marked fields into type="number" or type="date". At the
minimum, we would need to document that the default behavior is
changing.

-Paul



On Dec 28, 1:35 am, Aymeric Augustin

Jonas H.

unread,
Dec 28, 2011, 11:01:42 AM12/28/11
to django-d...@googlegroups.com
On 12/28/2011 05:15 AM, poswald wrote:
> I have a concern regarding this.. A few times I have tried to
> integrate django-floppyforms which takes a similar approach to what
> the html5 widgets offer (input types are specified by default) and it
> often causes pain. The reason is that while browsers say they support
> html5 input types sometimes that support is lacking or very badly
> implemented. As an example, if you say<input type="date"
> value="2011-12-28"> the only officially supported date format is an
> RFC-3339 'full-date' format (YYYY-MM-DD) according to the spec:
>
> http://dev.w3.org/html5/markup/input.date.html#input.date.attrs.value
> http://tools.ietf.org/html/rfc3339
>
> This means that you cannot have any other format of date string in
> that form field.
>
> Now, this ticket 16630 doesn't change the date field specifically but
> it does change the number field. (Is there a similar ticket for
> changing the date field?) I've run into a similar problem with the
> type='number' that this ticket does change. The problem I ran into was
> that forms cannot easily use the THOUSANDS_SEPARATOR because it is not
> a valid number. It has to be a 'float' to be valid. This means
> technically you need to use the text widget for that.

The reason why I decided to not include the 'date' type in the patch was
indeed the lack of browser support for non-anglophone input formats.

Seems like this needs to be extended to numbers as well.

Mikhail Korobov

unread,
Dec 29, 2011, 8:20:44 AM12/29/11
to django-d...@googlegroups.com
+1 for Paul's concerns. I think this at least should be opt-in. 

It can be also more or less implemented without custom widgets but using Gregor Müllegger's form-rendering branch (which is not merged but available as https://github.com/SmileyChris/django-forms app if I understand it properly) - or with some other external app like http://pypi.python.org/pypi/django-widget-tweaks/ 

среда, 28 декабря 2011 г. 10:15:49 UTC+6 пользователь poswald написал:

Stephen Burrows

unread,
Oct 1, 2012, 6:53:05 PM10/1/12
to django-d...@googlegroups.com
Hey all - Last I heard, today was the last day for new features for 1.5. I was triaging tickets yesterday and ran this ticket. [1] The ticket looks fine, and it addresses the issues raised here. The only new issue (raised on the ticket) is that this change could break third-party javascript and css if anyone is relying on those fields having type="text". Although this is a valid concern, I still think it would be worth switching over to HTML5 at long last – perhaps with a slightly more explicit warning in the backwards-compatibility section of the release notes so that designers know they need to watch out for that.

Since the only obstacle seems to be getting some sort of consensus among core devs that this is a change that's okay to make, I was hoping to get some feedback, and maybe get the patch merged in.

Best,

Felipe Prenholato

unread,
Oct 9, 2012, 10:04:30 AM10/9/12
to django-d...@googlegroups.com
If matters, +1.

People can easily change from $('input[type=text]') to $('input[type=text],input[type=email]'), it's a easy, no pain change, with various benefits of HTML5 fields.

I would only suggest that people can do something like number_field=IntegerField(html5=False) in form (at least in 1.5) so fields back to input type=text in rendering and who don't wanna touch css/js and third party apps to fix the code, just put this and everything works.

Felipe 'chronos' Prenholato.
Linux User nº 405489
Home page: http://devwithpassion.com | http://chronosbox.org/blog
GitHub: http://github.com/chronossc/ | Twitter: http://twitter.com/chronossc


2012/10/1 Stephen Burrows <stephen....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/FSBHz8GBxAIJ.

To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.

Reply all
Reply to author
Forward
0 new messages