Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions django/contrib/admin/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion django/db/backends/postgresql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def assemble_as_sql(self, fields, value_rows):
or any(any(hasattr(value, "as_sql") for value in row) for row in value_rows)
):
return super().assemble_as_sql(fields, value_rows)
db_types = [field.db_type(self.connection) for field in fields]
# Manually remove parameters from `db_type` to ensure no data
# truncation takes place (e.g. varchar[] instead of varchar(50)[]).
db_types = [field.db_type(self.connection).split("(")[0] for field in fields]
return InsertUnnest(["(%%s)::%s[]" % db_type for db_type in db_types]), [
list(map(list, zip(*value_rows)))
]
2 changes: 1 addition & 1 deletion django/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
6 changes: 5 additions & 1 deletion docs/releases/5.2.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ Django 5.2.10 release notes

*Expected January 6, 2026*

Django 5.2.10 fixes several bugs in 5.2.9.
Django 5.2.10 fixes a data loss bug in Django 5.2 and one bug related to
support for Python 3.14.

Bugfixes
========

* Fixed a bug in Django 5.2 where data exceeding ``max_length`` was silently
truncated by :meth:`.QuerySet.bulk_create` on PostgreSQL (:ticket:`33647`).

* Fixed a bug where management command colorized help (introduced in
Python 3.14) ignored the :option:`--no-color` option and the
:envvar:`DJANGO_COLORS` setting (:ticket:`36376`).
9 changes: 8 additions & 1 deletion docs/releases/6.0.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ Django 6.0.1 release notes

*Expected January 6, 2026*

Django 6.0.1 fixes several bugs in 6.0.
Django 6.0.1 fixes one data loss bug in Django 5.2 and several bugs in 6.0.

Bugfixes
========

* Fixed a bug in Django 5.2 where data exceeding ``max_length`` was silently
truncated by :meth:`.QuerySet.bulk_create` on PostgreSQL (:ticket:`33647`).

* Fixed a regression in Django 6.0 where :ttag:`querystring` mishandled
multi-value :class:`~django.http.QueryDict` keys, both by only preserving the
last value and by incorrectly handling ``None`` values (:ticket:`36783`).
Expand All @@ -35,3 +38,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`).
10 changes: 10 additions & 0 deletions tests/backends/postgresql/test_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from django.db import connection
from django.db.models.expressions import RawSQL
from django.db.utils import DataError
from django.test import TestCase

from ..models import Article, Reporter, Square
Expand Down Expand Up @@ -48,3 +49,12 @@ def test_unnest_eligible_foreign_keys(self):
self.assertEqual(
[article.reporter for article in articles], [reporter, reporter]
)

def test_parametrized_db_type(self):
with self.assertRaises(DataError):
Reporter.objects.bulk_create(
[
Reporter(),
Reporter(first_name="a" * 31),
]
)
15 changes: 7 additions & 8 deletions tests/forms_tests/widget_tests/test_clearablefileinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,18 @@ class TestForm(Form):
)

form = TestForm()
self.assertIs(self.widget.use_fieldset, True)
self.assertIs(self.widget.use_fieldset, False)
self.assertHTMLEqual(
"<div><fieldset><legend>Field:</legend>"
'<input id="id_field" name="field" type="file" required></fieldset></div>'
"<div><fieldset><legend>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>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(),
)

Expand Down