summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-02-23 09:45:56 +0100
committerClaude Paroz <claude@2xlibre.net>2013-02-23 10:18:08 +0100
commit7ec2a21be15af5b2c7513482c3bcfdd1e12782ed (patch)
tree13c7d8bdaca60c246d6de8166ad3f66f04dc7a58 /docs
parentdcf651c27edff13236fda0a480059b57dbe6e074 (diff)
Fixed #19686 -- Added HTML5 number input type
Thanks Simon Charette for his help on the patch. Refs #16630.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/forms/fields.txt9
-rw-r--r--docs/ref/forms/widgets.txt13
-rw-r--r--docs/releases/1.6.txt13
-rw-r--r--docs/topics/forms/formsets.txt6
4 files changed, 31 insertions, 10 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index 2e4e779f0c..85650adcf4 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -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
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index 970901a9ae..7218e41082 100644
--- a/docs/ref/forms/widgets.txt
+++ b/docs/ref/forms/widgets.txt
@@ -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``
~~~~~~~~~~~~~~
diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt
index d7b1547a91..67c032a362 100644
--- a/docs/releases/1.6.txt
+++ b/docs/releases/1.6.txt
@@ -60,9 +60,13 @@ Minor features
* In addition to :lookup:`year`, :lookup:`month` and :lookup:`day`, the ORM
now supports :lookup:`hour`, :lookup:`minute` and :lookup:`second` lookups.
-* The default widgets for :class:`~django.forms.EmailField` and
- :class:`~django.forms.URLField` use the new type attributes available in
- HTML5 (type='email', type='url').
+* The default widgets for :class:`~django.forms.EmailField`,
+ :class:`~django.forms.URLField`, :class:`~django.forms.IntegerField`,
+ :class:`~django.forms.FloatField` and :class:`~django.forms.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.
* The ``number`` argument for :ref:`lazy plural translations
<lazy-plural-translations>` can be provided at translation time rather than
@@ -122,7 +126,8 @@ Backwards incompatible changes in 1.6
* If your CSS/Javascript code used to access HTML input widgets by type, you
should review it as ``type='text'`` widgets might be now output as
- ``type='email'`` or ``type='url'`` depending on their corresponding field type.
+ ``type='email'``, ``type='url'`` or ``type='number'`` depending on their
+ corresponding field type.
* Extraction of translatable literals from templates with the
:djadmin:`makemessages` command now correctly detects i18n constructs when
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt
index d2d102b5d6..2534947dd3 100644
--- a/docs/topics/forms/formsets.txt
+++ b/docs/topics/forms/formsets.txt
@@ -273,13 +273,13 @@ Lets you create a formset with the ability to order::
... print(form.as_table())
<tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" value="Article #1" id="id_form-0-title" /></td></tr>
<tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" value="2008-05-10" id="id_form-0-pub_date" /></td></tr>
- <tr><th><label for="id_form-0-ORDER">Order:</label></th><td><input type="text" name="form-0-ORDER" value="1" id="id_form-0-ORDER" /></td></tr>
+ <tr><th><label for="id_form-0-ORDER">Order:</label></th><td><input type="number" name="form-0-ORDER" value="1" id="id_form-0-ORDER" /></td></tr>
<tr><th><label for="id_form-1-title">Title:</label></th><td><input type="text" name="form-1-title" value="Article #2" id="id_form-1-title" /></td></tr>
<tr><th><label for="id_form-1-pub_date">Pub date:</label></th><td><input type="text" name="form-1-pub_date" value="2008-05-11" id="id_form-1-pub_date" /></td></tr>
- <tr><th><label for="id_form-1-ORDER">Order:</label></th><td><input type="text" name="form-1-ORDER" value="2" id="id_form-1-ORDER" /></td></tr>
+ <tr><th><label for="id_form-1-ORDER">Order:</label></th><td><input type="number" name="form-1-ORDER" value="2" id="id_form-1-ORDER" /></td></tr>
<tr><th><label for="id_form-2-title">Title:</label></th><td><input type="text" name="form-2-title" id="id_form-2-title" /></td></tr>
<tr><th><label for="id_form-2-pub_date">Pub date:</label></th><td><input type="text" name="form-2-pub_date" id="id_form-2-pub_date" /></td></tr>
- <tr><th><label for="id_form-2-ORDER">Order:</label></th><td><input type="text" name="form-2-ORDER" id="id_form-2-ORDER" /></td></tr>
+ <tr><th><label for="id_form-2-ORDER">Order:</label></th><td><input type="number" name="form-2-ORDER" id="id_form-2-ORDER" /></td></tr>
This adds an additional field to each form. This new field is named ``ORDER``
and is an ``forms.IntegerField``. For the forms that came from the initial