diff options
| author | Alexander Gaevsky <sasha@sasha0.ru> | 2016-04-14 20:12:30 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-10 18:23:18 -0400 |
| commit | 536db42cf01ebe0dd633b131c3dbfc0bf743064f (patch) | |
| tree | b41566d66d755d438a87bd95be0d28887a04c919 | |
| parent | 2d26b4637f0318736955b54b34f270fe9500f795 (diff) | |
Fixed #26097 -- Added password_validators_help_text_html to UserCreationForm.
| -rw-r--r-- | django/contrib/admin/static/admin/css/base.css | 6 | ||||
| -rw-r--r-- | django/contrib/auth/forms.py | 1 | ||||
| -rw-r--r-- | docs/releases/1.11.txt | 3 | ||||
| -rw-r--r-- | tests/auth_tests/test_forms.py | 10 |
4 files changed, 19 insertions, 1 deletions
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, + '<ul><li>Your password can't be too similar to your other personal information.</li></ul>' + ) + # To verify that the login form rejects inactive users, use an authentication # backend that allows them. |
