I’m implementing authentication in a Django site using the built-in auth module, including the built-in UserCreationForm.
I’d like to set a minimum length for passwords. However, I can’t find any documentation on how to do this.
Can I configure the auth module’s User module to require this at the database level? Or should I sub-class the UserCreationForm (I’m actually doing this already for unrelated reasons) and add an extra validator that enforces the password length?
Especially if you’re already using a sub-classed
UserCreationForm, I’d say you should definitely just add the validation to it. You should be able to override theclean_passwordmethod on the form: