[1.11.x] Fixed #28303 -- Prevented localization of attribute values in the DTL attrs.html widget template.
Backport of 3b050fd0d0
from master
This commit is contained in:
parent
49de4f1541
commit
f0ec88fb63
|
@ -1 +1 @@
|
||||||
{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value }}"{% endif %}{% endif %}{% endfor %}
|
{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}{% endfor %}
|
|
@ -40,3 +40,7 @@ Bugfixes
|
||||||
context. It's now an empty string (as it is for the original function-based
|
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
|
``login()`` view) if the corresponding parameter isn't sent in a request (in
|
||||||
particular, when the login page is accessed directly) (:ticket:`28229`).
|
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`).
|
||||||
|
|
|
@ -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" />'
|
||||||
|
)
|
Loading…
Reference in New Issue