0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Fixed #27759 -- Prevented forms attrs.html template from rendering False attrs.

Regression in b52c73008a.
This commit is contained in:
Jon Dufresne 2017-01-22 10:15:56 -08:00 committed by Tim Graham
parent 88183117c2
commit 5fa390ee81
3 changed files with 6 additions and 2 deletions

View File

@ -1 +1 @@
{% for name, value in widget.attrs.items() %} {{ name }}{% if not value is sameas True %}="{{ value }}"{% endif %}{% endfor %}
{% for name, value in widget.attrs.items() %}{% if value is not sameas False %} {{ name }}{% if not value is sameas True %}="{{ value }}"{% endif %}{% endif %}{% endfor %}

View File

@ -1 +1 @@
{% for name, value in widget.attrs.items %} {{ name }}{% if not value is True %}="{{ value }}"{% endif %}{% endfor %}
{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if not value is True %}="{{ value }}"{% endif %}{% endif %}{% endfor %}

View File

@ -13,3 +13,7 @@ class WidgetTests(WidgetTest):
def test_no_trailing_newline_in_attrs(self):
self.check_html(Input(), 'name', 'value', strict=True, html='<input type="None" name="name" value="value" />')
def test_attr_false_not_rendered(self):
html = '<input type="None" name="name" value="value" />'
self.check_html(Input(), 'name', 'value', html=html, attrs={'readonly': False})