diff --git a/django/contrib/admin/static/admin/css/base.css b/django/contrib/admin/static/admin/css/base.css index 67aa3143a5..466b36bcec 100644 --- a/django/contrib/admin/static/admin/css/base.css +++ b/django/contrib/admin/static/admin/css/base.css @@ -187,11 +187,15 @@ p.mini { margin-top: -3px; } -.help, p.help, form p.help, div.help, form div.help { +.help, p.help, form p.help, div.help, form div.help, div.help li { font-size: 11px; color: #999; } +div.help ul { + margin-bottom: 0; +} + .help-tooltip { cursor: help; } diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index b1dd713937..ddd915ae69 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -79,6 +79,7 @@ class UserCreationForm(forms.ModelForm): label=_("Password"), strip=False, widget=forms.PasswordInput, + help_text=password_validation.password_validators_help_text_html(), ) password2 = forms.CharField( label=_("Password confirmation"), diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt index 134d3d2515..49540a320a 100644 --- a/docs/releases/1.11.txt +++ b/docs/releases/1.11.txt @@ -106,6 +106,9 @@ Minor features :class:`~django.contrib.auth.views.LogoutView` allows specifying a set of hosts that are safe for redirecting after login and logout. +* Added password validators ``help_text`` to + :class:`~django.contrib.auth.forms.UserCreationForm`. + :mod:`django.contrib.contenttypes` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index dde639dc01..28a40db852 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -236,6 +236,16 @@ class UserCreationFormTest(TestDataMixin, TestCase): self.assertEqual(form.cleaned_data['password1'], data['password1']) self.assertEqual(form.cleaned_data['password2'], data['password2']) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, + ]) + def test_password_help_text(self): + form = UserCreationForm() + self.assertEqual( + form.fields['password1'].help_text, + '' + ) + # To verify that the login form rejects inactive users, use an authentication # backend that allows them.