From 16af0c60ed90813ed70ecef4e64a89301ed0f0a2 Mon Sep 17 00:00:00 2001 From: Richard Laager Date: Wed, 11 Sep 2024 22:45:55 -0500 Subject: [PATCH] Fixed #35755 -- Hid help text of hidden fields in admin fieldsets. Regression in 96a598356a9ea8c2c05b22cadc12e256a3b295fd. --- .../templates/admin/includes/fieldset.html | 2 +- tests/admin_inlines/models.py | 2 +- tests/admin_inlines/tests.py | 28 +++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html index a9d3f92702..8c1830da62 100644 --- a/django/contrib/admin/templates/admin/includes/fieldset.html +++ b/django/contrib/admin/templates/admin/includes/fieldset.html @@ -27,7 +27,7 @@ {% endif %} {% if field.field.help_text %} -
+
{{ field.field.help_text|safe }}
{% endif %} diff --git a/tests/admin_inlines/models.py b/tests/admin_inlines/models.py index 64aaca8d14..86a859727a 100644 --- a/tests/admin_inlines/models.py +++ b/tests/admin_inlines/models.py @@ -332,7 +332,7 @@ class SomeParentModel(models.Model): class SomeChildModel(models.Model): name = models.CharField(max_length=1) - position = models.PositiveIntegerField() + position = models.PositiveIntegerField(help_text="Position help_text.") parent = models.ForeignKey(SomeParentModel, models.CASCADE) readonly_field = models.CharField(max_length=1) diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index cba8db83d7..8e69edb841 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -349,7 +349,12 @@ class TestInline(TestDataMixin, TestCase): ) response = self.client.get(url) self.assertInHTML( - 'Position', + 'Position' + '' + "", response.rendered_content, ) self.assertInHTML( @@ -379,13 +384,15 @@ class TestInline(TestDataMixin, TestCase): self.assertInHTML( '', + '
0
' + '', response.rendered_content, ) self.assertInHTML( '', + '
1
' + '', response.rendered_content, ) @@ -407,13 +414,17 @@ class TestInline(TestDataMixin, TestCase): self.assertInHTML( '', + '
0
' + '' + "", response.rendered_content, ) self.assertInHTML( '', + '
1
' + '' + "", response.rendered_content, ) @@ -448,7 +459,12 @@ class TestInline(TestDataMixin, TestCase): self.assertInHTML( '' 'Name' - 'Position' + 'Position' + '' + "" "Delete?", response.rendered_content, )