summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-06-17 08:12:05 -0400
committerGitHub <noreply@github.com>2017-06-17 08:12:05 -0400
commit3b050fd0d0b8dbf499bdb44ce12fa926298c0bd0 (patch)
tree221f107ffc5324bc3bec9a111d5d417df912ee2e
parent2b09e4c88e96cb03b29f5a6b0e4838ab4271e631 (diff)
Fixed #28303 -- Prevented localization of attribute values in the DTL attrs.html widget template.
-rw-r--r--django/forms/templates/django/forms/widgets/attrs.html2
-rw-r--r--docs/releases/1.11.3.txt4
-rw-r--r--tests/forms_tests/widget_tests/test_numberinput.py15
3 files changed, 20 insertions, 1 deletions
diff --git a/django/forms/templates/django/forms/widgets/attrs.html b/django/forms/templates/django/forms/widgets/attrs.html
index c8bba9f35c..7a5592afcb 100644
--- a/django/forms/templates/django/forms/widgets/attrs.html
+++ b/django/forms/templates/django/forms/widgets/attrs.html
@@ -1 +1 @@
-{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value }}"{% endif %}{% endif %}{% endfor %} \ No newline at end of file
+{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}{% endfor %} \ No newline at end of file
diff --git a/docs/releases/1.11.3.txt b/docs/releases/1.11.3.txt
index 5ff33e42e6..1e2ddddb66 100644
--- a/docs/releases/1.11.3.txt
+++ b/docs/releases/1.11.3.txt
@@ -40,3 +40,7 @@ Bugfixes
context. It's now an empty string (as it is for the original function-based
``login()`` view) if the corresponding parameter isn't sent in a request (in
particular, when the login page is accessed directly) (:ticket:`28229`).
+
+* Prevented attribute values in the ``django/forms/widgets/attrs.html``
+ template from being localized so that numeric attributes (e.g. ``max`` and
+ ``min``) of ``NumberInput`` work correctly (:ticket:`28303`).
diff --git a/tests/forms_tests/widget_tests/test_numberinput.py b/tests/forms_tests/widget_tests/test_numberinput.py
new file mode 100644
index 0000000000..95a0a9250a
--- /dev/null
+++ b/tests/forms_tests/widget_tests/test_numberinput.py
@@ -0,0 +1,15 @@
+from django.forms.widgets import NumberInput
+from django.test import override_settings
+
+from .base import WidgetTest
+
+
+class NumberInputTests(WidgetTest):
+
+ @override_settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True)
+ def test_attrs_not_localized(self):
+ widget = NumberInput(attrs={'max': 12345, 'min': 1234, 'step': 9999})
+ self.check_html(
+ widget, 'name', 'value',
+ '<input type="number" name="name" value="value" max="12345" min="1234" step="9999" />'
+ )