'Enforce password policies (if applicable)'

def clean_password(self):

    password = self.cleaned_data['password']
    if (self.enforce_username_neq_password and ('username' in self.cleaned_data) and (self.cleaned_data['username'] == password)):
        raise ValidationError(_('Username    and    password    fields    cannot    match'))
    if self.enforce_password_policy:
        try:
            validate_password_strength(password)
        except ValidationError as err:
            raise ValidationError((_('Password:    ') + ';    '.join(err.messages)))
    return password
