diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html index ed4285855e..ac02e811ea 100644 --- a/django/contrib/admin/templates/admin/auth/user/change_password.html +++ b/django/contrib/admin/templates/admin/auth/user/change_password.html @@ -34,7 +34,7 @@ {{ form.password1.errors }} {{ form.password1.label_tag }} {{ form.password1 }} {% if form.password1.help_text %} -
{{ form.password1.help_text|safe }}
+
{% endif %}{{ form.password1.help_text|safe }}
{% endif %} @@ -42,7 +42,7 @@ {{ form.password2.errors }} {{ form.password2.label_tag }} {{ form.password2 }} {% if form.password2.help_text %} -
{{ form.password2.help_text|safe }}
+
{{ form.password2.help_text|safe }}
{% endif %} diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html index 218fd5a4c1..8207d47ec4 100644 --- a/django/contrib/admin/templates/admin/includes/fieldset.html +++ b/django/contrib/admin/templates/admin/includes/fieldset.html @@ -20,7 +20,9 @@ {% endif %} {% endif %} {% if field.field.help_text %} -
{{ field.field.help_text|safe }}
+
+ {{ field.field.help_text|safe }} +
{% endif %} {% endfor %} diff --git a/django/contrib/admin/templates/admin/search_form.html b/django/contrib/admin/templates/admin/search_form.html index fd7818a9f8..7f65211582 100644 --- a/django/contrib/admin/templates/admin/search_form.html +++ b/django/contrib/admin/templates/admin/search_form.html @@ -3,7 +3,7 @@
{% endif %} diff --git a/django/contrib/admin/templates/registration/password_change_form.html b/django/contrib/admin/templates/registration/password_change_form.html index 8c2913398c..e5fa9d8b99 100644 --- a/django/contrib/admin/templates/registration/password_change_form.html +++ b/django/contrib/admin/templates/registration/password_change_form.html @@ -39,7 +39,7 @@ {{ form.new_password1.errors }} {{ form.new_password1.label_tag }} {{ form.new_password1 }} {% if form.new_password1.help_text %} -
{{ form.new_password1.help_text|safe }}
+
{{ form.new_password1.help_text|safe }}
{% endif %} @@ -47,7 +47,7 @@ {{ form.new_password2.errors }} {{ form.new_password2.label_tag }} {{ form.new_password2 }} {% if form.new_password2.help_text %} -
{{ form.new_password2.help_text|safe }}
+
{{ form.new_password2.help_text|safe }}
{% endif %} diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 6ffcdc6497..e24654dfcb 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -1523,7 +1523,7 @@ class ChangeListTests(TestCase): request = self._mocked_authenticated_request("/band/", superuser) response = m.changelist_view(request) self.assertIsNone(response.context_data["cl"].search_help_text) - self.assertNotContains(response, '
') + self.assertNotContains(response, '
') # search_fields with search_help_text. m.search_help_text = "Search help text" request = self._mocked_authenticated_request("/band/", superuser) @@ -1531,7 +1531,14 @@ class ChangeListTests(TestCase): self.assertEqual( response.context_data["cl"].search_help_text, "Search help text" ) - self.assertContains(response, '
Search help text
') + self.assertContains( + response, '
Search help text
' + ) + self.assertContains( + response, + '', + ) class GetAdminLogTests(TestCase): diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 9002af9933..aab20dfd55 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -263,9 +263,7 @@ class TestInline(TestDataMixin, TestCase): stacked and tabular layouts. """ response = self.client.get(reverse("admin:admin_inlines_holder4_add")) - self.assertContains( - response, '
Awesome stacked help text is awesome.
', 4 - ) + self.assertContains(response, "Awesome stacked help text is awesome.", 4) self.assertContains( response, '' + ) + @override_settings( + AUTH_PASSWORD_VALIDATORS=[ + { + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) + }, + { + "NAME": ( + "django.contrib.auth.password_validation." "NumericPasswordValidator" + ) + }, + ], TEMPLATES=[ { "BACKEND": "django.template.backends.django.DjangoTemplates", @@ -1470,7 +1505,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): ], }, } - ] + ], ) class AdminCustomTemplateTests(AdminViewBasicTestCase): def test_custom_model_admin_templates(self): @@ -1563,6 +1598,19 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): response, '' ) + # help text for passwords has an id. + self.assertContains( + response, + '
  • ' + "Your password can’t be too similar to your other personal information." + "
  • Your password can’t be entirely numeric.
", + ) + self.assertContains( + response, + '
' + "Enter the same password as before, for verification.
", + ) + def test_extended_bodyclass_template_index(self): """ The admin/index.html template uses block.super in the bodyclass block. @@ -6271,17 +6319,17 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase): self.assertContains(response, '
') self.assertContains(response, '
') self.assertContains(response, '
') - self.assertContains(response, '
', 3) + self.assertContains(response, '
Some help text for the title (with Unicode ŠĐĆŽćžšđ)' - "
", + '
Some help text for the title ' + "(with Unicode ŠĐĆŽćžšđ)
", html=True, ) self.assertContains( response, - '
Some help text for the content (with Unicode ŠĐĆŽćžšđ)' - "
", + '
Some help text for the content ' + "(with Unicode ŠĐĆŽćžšđ)
", html=True, ) self.assertContains( @@ -6468,7 +6516,9 @@ class ReadonlyTest(AdminFieldExtractionMixin, TestCase): reverse("admin:admin_views_fieldoverridepost_change", args=(p.pk,)) ) self.assertContains( - response, '
Overridden help text for the date
' + response, + '
Overridden help text for the date
', + html=True, ) self.assertContains( response,