5👍
✅
The password is not validated because you are not calling any validator in your UserBaseCreationForm
. You can do this in different ways and the easiest one would be just inheriting UserCreationForm
from django.contrib.auth.forms
.
Check the django source code, it calls the password validators in _post_clean
.
0👍
According to Django Docs, Django uses a validate_password method from django.contrib.auth.password_validation.validate_password to validate the password.
Since you are using a Custom UserCreationForm, You need to call that validate_password method explicitly, by implementing a form validation through password field clean method.
Simply add following code snippet in your UserBaseCreationForm class.
def clean_password1(self):
password = self.cleaned_data.get('password1')
if password:
try:
password_validation.validate_password(password, self.instance)
except ValidationError as error:
self.add_error('password1', error)
- [Django]-Django ValueError: 'dtedeclared with a lazy reference to …..' when changed Model Name
- [Django]-Session being reset by django-all auth
- [Django]-How to display a quote in django template
- [Django]-Manage.py runserver in virtualenv using wrong django version
Source:stackexchange.com