From e014f91a70aa3ccdddb363a733c76e35597424fa Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Tue, 5 Dec 2017 14:42:10 +0000 Subject: [PATCH] Fixed #28890 -- Removed newlines between MultiWidget's subwidgets. Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01. --- django/forms/jinja2/django/forms/widgets/multiwidget.html | 2 +- .../forms/templates/django/forms/widgets/multiwidget.html | 2 +- docs/releases/1.11.9.txt | 3 ++- docs/releases/2.0.1.txt | 3 ++- tests/forms_tests/widget_tests/test_multiwidget.py | 7 +++++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/django/forms/jinja2/django/forms/widgets/multiwidget.html b/django/forms/jinja2/django/forms/widgets/multiwidget.html index 0030711182..ae120e91f5 100644 --- a/django/forms/jinja2/django/forms/widgets/multiwidget.html +++ b/django/forms/jinja2/django/forms/widgets/multiwidget.html @@ -1 +1 @@ -{% for widget in widget.subwidgets %}{% include widget.template_name %}{% endfor %} +{% for widget in widget.subwidgets -%}{% include widget.template_name %}{%- endfor %} diff --git a/django/forms/templates/django/forms/widgets/multiwidget.html b/django/forms/templates/django/forms/widgets/multiwidget.html index 0030711182..7e687a136b 100644 --- a/django/forms/templates/django/forms/widgets/multiwidget.html +++ b/django/forms/templates/django/forms/widgets/multiwidget.html @@ -1 +1 @@ -{% for widget in widget.subwidgets %}{% include widget.template_name %}{% endfor %} +{% spaceless %}{% for widget in widget.subwidgets %}{% include widget.template_name %}{% endfor %}{% endspaceless %} diff --git a/docs/releases/1.11.9.txt b/docs/releases/1.11.9.txt index 851f1f64c1..20d587248f 100644 --- a/docs/releases/1.11.9.txt +++ b/docs/releases/1.11.9.txt @@ -9,4 +9,5 @@ Django 1.11.9 fixes several bugs in 1.11.8. Bugfixes ======== -* ... +* Fixed a regression in Django 1.11 that added newlines between ``MultiWidget``'s + subwidgets (:ticket:`28890`). diff --git a/docs/releases/2.0.1.txt b/docs/releases/2.0.1.txt index 431950ef53..09b52ec4fc 100644 --- a/docs/releases/2.0.1.txt +++ b/docs/releases/2.0.1.txt @@ -9,4 +9,5 @@ Django 2.0.1 fixes several bugs in 2.0. Bugfixes ======== -* ... +* Fixed a regression in Django 1.11 that added newlines between ``MultiWidget``'s + subwidgets (:ticket:`28890`). diff --git a/tests/forms_tests/widget_tests/test_multiwidget.py b/tests/forms_tests/widget_tests/test_multiwidget.py index 6266cc70d0..f452ad2ad3 100644 --- a/tests/forms_tests/widget_tests/test_multiwidget.py +++ b/tests/forms_tests/widget_tests/test_multiwidget.py @@ -166,6 +166,13 @@ class MultiWidgetTest(WidgetTest): """ )) + def test_no_whitespace_between_widgets(self): + widget = MyMultiWidget(widgets=(TextInput, TextInput())) + self.check_html(widget, 'code', None, html=( + '' + '' + ), strict=True) + def test_deepcopy(self): """ MultiWidget should define __deepcopy__() (#12048).