Fixed #26097 -- Added password_validators_help_text_html to UserCreationForm.
This commit is contained in:
parent
2d26b4637f
commit
536db42cf0
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue