diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 760579ebe5..fffa7430fc 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -884,9 +884,9 @@ class MultiWidget(Widget): if self.is_localized: for widget in self.widgets: widget.is_localized = self.is_localized - # value is a list of values, each corresponding to a widget + # value is a list/tuple of values, each corresponding to a widget # in self.widgets. - if not isinstance(value, list): + if not isinstance(value, (list, tuple)): value = self.decompress(value) final_attrs = context["widget"]["attrs"] diff --git a/tests/forms_tests/widget_tests/test_multiwidget.py b/tests/forms_tests/widget_tests/test_multiwidget.py index aac859a4b8..40f099e625 100644 --- a/tests/forms_tests/widget_tests/test_multiwidget.py +++ b/tests/forms_tests/widget_tests/test_multiwidget.py @@ -130,6 +130,15 @@ class MultiWidgetTest(WidgetTest): '' ), ) + self.check_html( + widget, + "name", + ("john", "lennon"), + html=( + '' + '' + ), + ) self.check_html( widget, "name", diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py index 86722a9f46..1b155ed51a 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -1094,3 +1094,15 @@ class TestWidget(PostgreSQLSimpleTestCase): '' '', ) + + def test_range_widget_render_tuple_value(self): + field = pg_forms.ranges.DateTimeRangeField() + dt_range_tuple = ( + datetime.datetime(2022, 4, 22, 10, 24), + datetime.datetime(2022, 5, 12, 9, 25), + ) + self.assertHTMLEqual( + field.widget.render("datetimerange", dt_range_tuple), + '' + '', + )