From 2c029c718f45341cdd43ee094c24488743c633e6 Mon Sep 17 00:00:00 2001 From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:27:57 +0100 Subject: [PATCH] Fixed #35876 -- Displayed non-ASCII fieldset names when rendering ModelAdmin.fieldsets. Thank you to Namhong Kim for the report, and to Mariusz Felisiak and Marijke Luttekes for the review. Regression in 01ed59f753139afb514170ee7f7384c155ecbc2d. --- .../admin/templates/admin/includes/fieldset.html | 10 ++++------ docs/releases/5.1.3.txt | 3 +++ tests/admin_inlines/tests.py | 4 ++-- tests/admin_views/admin.py | 1 + tests/admin_views/tests.py | 13 +++++++++++++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html index 8c1830da62..9c9b31965a 100644 --- a/django/contrib/admin/templates/admin/includes/fieldset.html +++ b/django/contrib/admin/templates/admin/includes/fieldset.html @@ -1,8 +1,7 @@ -{% with name=fieldset.name|default:""|slugify %} -
- {% if name %} +
+ {% if fieldset.name %} {% if fieldset.is_collapsible %}
{% endif %} - {{ fieldset.name }} + {{ fieldset.name }} {% if fieldset.is_collapsible %}{% endif %} {% endif %} {% if fieldset.description %} @@ -36,6 +35,5 @@ {% if not line.fields|length == 1 %}{% endif %} {% endfor %} - {% if name and fieldset.is_collapsible %}
{% endif %} + {% if fieldset.name and fieldset.is_collapsible %}{% endif %}
-{% endwith %} diff --git a/docs/releases/5.1.3.txt b/docs/releases/5.1.3.txt index 0dd5b42cb8..2ef34bfc8a 100644 --- a/docs/releases/5.1.3.txt +++ b/docs/releases/5.1.3.txt @@ -17,3 +17,6 @@ Bugfixes * Fixed a regression in Django 5.1 that prevented the use of DB-IP databases with :class:`~django.contrib.gis.geoip2.GeoIP2` (:ticket:`35841`). + +* Fixed a regression in Django 5.1 where non-ASCII fieldset names were not + displayed when rendering admin fieldsets (:ticket:`35876`). diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 8e69edb841..9c32f6fb8e 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -1801,7 +1801,7 @@ class TestInlineWithFieldsets(TestDataMixin, TestCase): # The second and third have the same "Advanced options" name, but the # second one has the "collapse" class. for x, classes in ((1, ""), (2, "collapse")): - heading_id = f"fieldset-0-advanced-options-{x}-heading" + heading_id = f"fieldset-0-{x}-heading" with self.subTest(heading_id=heading_id): self.assertContains( response, @@ -1846,7 +1846,7 @@ class TestInlineWithFieldsets(TestDataMixin, TestCase): # Every fieldset defined for an inline's form. for z, fieldset in enumerate(inline_admin_form): if fieldset.name: - heading_id = f"{prefix}-{y}-details-{z}-heading" + heading_id = f"{prefix}-{y}-{z}-heading" self.assertContains( response, f'
' ) + self.assertContains( + response, + '

Some fields

', + ) + self.assertContains( + response, + '

' + "Some other fields

", + ) + self.assertContains( + response, + '

이름

', + ) post = self.client.post( reverse("admin:admin_views_article_add"), add_dict, follow=False )