Skip to content

Commit 3b050fd

Browse files
authored
Fixed #28303 -- Prevented localization of attribute values in the DTL attrs.html widget template.
1 parent 2b09e4c commit 3b050fd

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value }}"{% endif %}{% endif %}{% endfor %}
1+
{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}{% endfor %}

docs/releases/1.11.3.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ Bugfixes
4040
context. It's now an empty string (as it is for the original function-based
4141
``login()`` view) if the corresponding parameter isn't sent in a request (in
4242
particular, when the login page is accessed directly) (:ticket:`28229`).
43+
44+
* Prevented attribute values in the ``django/forms/widgets/attrs.html``
45+
template from being localized so that numeric attributes (e.g. ``max`` and
46+
``min``) of ``NumberInput`` work correctly (:ticket:`28303`).
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from django.forms.widgets import NumberInput
2+
from django.test import override_settings
3+
4+
from .base import WidgetTest
5+
6+
7+
class NumberInputTests(WidgetTest):
8+
9+
@override_settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True)
10+
def test_attrs_not_localized(self):
11+
widget = NumberInput(attrs={'max': 12345, 'min': 1234, 'step': 9999})
12+
self.check_html(
13+
widget, 'name', 'value',
14+
'<input type="number" name="name" value="value" max="12345" min="1234" step="9999" />'
15+
)

0 commit comments

Comments
 (0)