Im having this error on the console
File "c:\Users\onlyj\Desktop\Repo Git\Flask\Flask App\main\routes.py", line 192, in send_reset_email
token = user.get
_reset_token()
AttributeError: 'User' object has no attribute'get_reset_to ST /reset_password HTTP/1.1" 500 -
def send_reset_email(user):
token = user.get_reset_token()
msg = Message('Password Reset Request',
sender = 'onlyjungletom@gmail.com',
recipients = [user.email])
msg.body = f'''To reset yor password, visit the following link:
{url_for('reset_token', token = token, _external = True)}
If you did not make this request then simply ignore this email and no changes will be made.
'''
mail.send()
So, when i hit the "Send pass reset "button on the web page i get this error "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
And this is the User model on models.py :
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key = True)
username = db.Column(db.String(20), unique = True, nullable = False)
email = db.Column(db.String(120), unique = True, nullable = False)
image_file = db.Column(db.String(20), nullable = False, default = 'default.jpg')
password = db.Column(db.String(60), nullable = False)
posts = db.relationship('Post', backref = 'author', lazy = True)
def __repr__(self):
return f"User('{self.username}'), '{self.email}', '{self.image_file}')"