1👍
Cleaned data isn’t an attribute when you create a form, it is added when you call is_valid() on a form.
is_valid() will check that the data conforms to the constraint you put on it when creating the form (in this case, matching passwords and unique email by default for a RegistrationFormUniqueEmail). It might make sense to overwrite the is_valid() or create another function that calls is_valid() in addition to performing additional checks on password strength, instead of performing additional validation outside of the standard procedure
def custom_is_valid(self):
valid = self.is_valid()
if password.is.not.secure():
self.add_error('password', ValidationError(('Insecure Password'), code='invalid'))
valid = False
return valid
The above snipped might do the trick. The string ‘password’ in adding the error tacks it onto the form field you indicate, you may want to use password1 or password2 because I think that’s the field name for the build in form you’re using. Also, you wouldn’t use cleaned_data to check password validity. You would just use the data attribute, form.data[‘password’]