diff options
| author | Johannes Maron <johannes@maron.family> | 2025-12-27 12:28:26 +0100 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-31 10:18:06 -0500 |
| commit | b7b5465b1c026dda7de646fca15ca1e97886d021 (patch) | |
| tree | e1c0da5fd91ee9921b0488790021e071b2d40408 | |
| parent | 90daa655486c7fc69e9dad41c5e96f00339a3b9b (diff) | |
[6.0.x] Fixed #36829 -- Reverted value of ClearableFileInput.use_fieldset to True.
There was unresolved discussion regarding whether to set
ClearableFileInput.use_fieldset to True or False when use_fieldset was
introduced in Django 4.1, since the clear checkbox appears only
sometimes. Although using <fieldset> is likely desirable, since the
primary motivation in #35892 was just to improve markup in the admin,
and a deprecation path was not provided for general form usage, future
work is deferred to #36828.
Regression in 4187da258fe212d494cb578a0bc2b52c4979ab95.
Thanks Tim Graham, Antoliny, and David Smith for triage.
| -rw-r--r-- | django/contrib/admin/widgets.py | 1 | ||||
| -rw-r--r-- | django/forms/widgets.py | 2 | ||||
| -rw-r--r-- | docs/releases/6.0.1.txt | 4 | ||||
| -rw-r--r-- | tests/forms_tests/widget_tests/test_clearablefileinput.py | 15 |
4 files changed, 13 insertions, 9 deletions
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index 81b57f33aa..f5c3939012 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -122,6 +122,7 @@ class AdminRadioSelect(forms.RadioSelect): class AdminFileWidget(forms.ClearableFileInput): template_name = "admin/widgets/clearable_file_input.html" + use_fieldset = True def url_params_from_lookup_dict(lookups): diff --git a/django/forms/widgets.py b/django/forms/widgets.py index b77e57abce..1bcfeba288 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -530,7 +530,7 @@ class ClearableFileInput(FileInput): input_text = _("Change") template_name = "django/forms/widgets/clearable_file_input.html" checked = False - use_fieldset = True + use_fieldset = False def clear_checkbox_name(self, name): """ diff --git a/docs/releases/6.0.1.txt b/docs/releases/6.0.1.txt index 753d2c87ad..bb1dfab2c9 100644 --- a/docs/releases/6.0.1.txt +++ b/docs/releases/6.0.1.txt @@ -35,3 +35,7 @@ Bugfixes * Fixed a regression in Django 6.0 where :func:`~django.urls.path` routes defined using :func:`~django.utils.translation.gettext_lazy` failed to resolve correctly (:ticket:`36796`). + +* Fixed a regression in Django 6.0 where the :attr:`.Widget.use_fieldset` + attribute of :class:`~django.forms.ClearableFileInput` was flipped + from ``False`` to ``True`` (:ticket:`36829`). diff --git a/tests/forms_tests/widget_tests/test_clearablefileinput.py b/tests/forms_tests/widget_tests/test_clearablefileinput.py index 8d3bff4b45..ae54cc4b5d 100644 --- a/tests/forms_tests/widget_tests/test_clearablefileinput.py +++ b/tests/forms_tests/widget_tests/test_clearablefileinput.py @@ -246,19 +246,18 @@ class ClearableFileInputTest(WidgetTest): ) form = TestForm() - self.assertIs(self.widget.use_fieldset, True) + self.assertIs(self.widget.use_fieldset, False) self.assertHTMLEqual( - '<div><fieldset><legend for="id_field">Field:</legend>' - '<input id="id_field" name="field" type="file" required></fieldset></div>' - '<div><fieldset><legend for="id_with_file">With file:</legend>Currently: ' + '<div><label for="id_field">Field:</label>' + '<input id="id_field" name="field" type="file" required></div>' + '<div><label for="id_with_file">With file:</label>Currently: ' '<a href="something">something</a><br>Change:<input type="file" ' - 'name="with_file" id="id_with_file"></fieldset></div>' - '<div><fieldset><legend for="id_clearable_file">Clearable file:</legend>' + 'name="with_file" id="id_with_file"></div>' + '<div><label for="id_clearable_file">Clearable file:</label>' 'Currently: <a href="something">something</a><input ' 'type="checkbox" name="clearable_file-clear" id="clearable_file-clear_id">' '<label for="clearable_file-clear_id">Clear</label><br>Change:' - '<input type="file" name="clearable_file" id="id_clearable_file">' - "</fieldset></div>", + '<input type="file" name="clearable_file" id="id_clearable_file"></div>', form.render(), ) |
