我正在使用wtforms编写登录页面。这些字段是用户名和密码。以下是为两个字段定义的两个验证。如果用户名上的验证方法引发异常,是否有办法停止在密码字段上执行验证功能] >
def validate_username(self, field): # Check if not None for that username! print('Inside check_username') if User.query.filter_by(username=field.data).first() is None: raise ValidationError(f'Sorry username : {field.data} is not registered!') def validate_password(self, field): # Below is not the actual code.This method will contain code to check of valid password. raise ValidationError(f'Sorry username : {field.data} is not registered!')
现在正在发生的是上述两种方法都被调用,这是可以预期的,但是如果用户名不存在,我不想检查密码
我正在使用wtforms编写登录页面。字段是用户名和密码。下面是为两个字段定义的两个验证。是否有一种方法可以停止在...上执行验证功能?