1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #19686 -- Added HTML5 number input type

Thanks Simon Charette for his help on the patch. Refs #16630.
This commit is contained in:
Claude Paroz
2013-02-23 09:45:56 +01:00
parent dcf651c27e
commit 7ec2a21be1
12 changed files with 148 additions and 67 deletions

View File

@@ -454,7 +454,8 @@ For each field, we describe the default widget used if you don't specify
.. class:: DecimalField(**kwargs)
* Default widget: :class:`TextInput`
* Default widget: :class:`NumberInput` when :attr:`Field.localize` is
``False``, else :class:`TextInput`.
* Empty value: ``None``
* Normalizes to: A Python ``decimal``.
* Validates that the given value is a decimal. Leading and trailing
@@ -580,7 +581,8 @@ For each field, we describe the default widget used if you don't specify
.. class:: FloatField(**kwargs)
* Default widget: :class:`TextInput`
* Default widget: :class:`NumberInput` when :attr:`Field.localize` is
``False``, else :class:`TextInput`.
* Empty value: ``None``
* Normalizes to: A Python float.
* Validates that the given value is an float. Leading and trailing
@@ -621,7 +623,8 @@ For each field, we describe the default widget used if you don't specify
.. class:: IntegerField(**kwargs)
* Default widget: :class:`TextInput`
* Default widget: :class:`NumberInput` when :attr:`Field.localize` is
``False``, else :class:`TextInput`.
* Empty value: ``None``
* Normalizes to: A Python integer or long integer.
* Validates that the given value is an integer. Leading and trailing

View File

@@ -389,6 +389,19 @@ These widgets make use of the HTML elements ``input`` and ``textarea``.
Text input: ``<input type="text" ...>``
``NumberInput``
~~~~~~~~~~~~~~~
.. class:: NumberInput
.. versionadded:: 1.6
Text input: ``<input type="number" ...>``
Beware that not all browsers support entering localized numbers in
``number`` input types. Django itself avoids using them for fields having
their :attr:`~django.forms.Field.localize` property to ``True``.
``EmailInput``
~~~~~~~~~~~~~~