validation - Stop displaying help text from custom password validator using django allauth - Stack Overflow

I am trying to make a custom password validator and I got a problem where the HTML page renders return

I am trying to make a custom password validator and I got a problem where the HTML page renders return string from get_help_text(). I found that the help text is being displayed before I enter a password for the signup page, and it is still there after ValidationError occurs due to invalid input

I don't have any html file for the sign up page and I'm seeing the default UI provided by allauth. enter image description here

This is my validators.py

class CustomPasswordValidator:
    def validate(self, password, user=None):
        if (
                len(password) < 8 or
                not contains_uppercase_letter(password) or
                not contains_lowercase_letter(password) or
                not contains_number(password) or
                not contains_special_character(password)
        ):
            raise ValidationError("Password must be at least 8 chracters that are a combination of uppercase letter, lowercase letter, numbers and special characters.")

    def get_help_text(self):
        return "Enter at least 8 characters that are a combination of uppercase letter, lowercase letter, numbers and special characters."
        

def validate_no_special_characters(value):
    if contains_special_character(value):
        raise ValidationError("Cannot contain special characters.")

and this is a part of my settings.py

AUTH_PASSWORD_VALIDATORS = [
    {
      "NAME":"appname.validators.CustomPasswordValidator",
    },
]
...

ACCOUNT_PASSWORD_INPUT_RENDER_VALUE = True

I tried returning empty string in get_help_text() but the html page displayed ul list with no content. I don't even want the list on the html page. How can I do this? enter image description here

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745638466a4637541.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信