Hello Everyone,
Due to some changes to flask_login library you need to make 2 changes to the naming of the methods used in the subsequent lectures.
How are they given
def check_email(self,field):
if User.query.filter_by(email=field.data).first():
raise ValidationError('Your email has been registered already!')
def check_username(self,field):
if User.query.filter_by(username=field.data).first():
raise ValidationError('Your username has been registered already!')
How should they be for the reg_form
def validate_email(self, email):
if User.query.filter_by(email=self.email.data).first():
raise ValidationError('Email has been registered')
def validate_username(self, username):
if User.query.filter_by(username=self.username.data).first():
raise ValidationError('Username has been registered')
How should they be for the update_user_form
def validate_email(self, email):
if email.data != current_user.email:
if User.query.filter_by(email=email.data).first():
raise ValidationError('Email has been registered')
def validate_username(self, username):
if username.data != current_user.username:
if User.query.filter_by(username=username.data).first():
raise ValidationError('Username has been registered')