Learn Flask Travel Sites LoginManager

Hi Everyone,

I am currently working on the travel sites project in learn flask. As soon as I import LoginManager I get this:


Exception: Missing user_loader or request_loader. Refer to Flask-Login — Flask-Login 0.4.1 documentation for more info.

I haven’t even called LoginManager yet, and it is giving me this error. I searched it up on stackoverflow but to no avail. This is my code:

from datetime import datetime
from werkzeug.security import generate_password_hash, check_password_hash
from app import db

class User(db.Model):
  posts = db.relationship('Post', backref='author', lazy='dynamic')
  id = db.Column(db.Integer, primary_key=True)
  email = db.Column(db.String(50), unique = True, index = True)
  password_hash = db.Column(db.String(128))
  username = db.Column(db.String(80), unique=True, index=True)
  def set_password(self, password):
  def check_password_hash(self, password):
  def __repr__(self):
        return '<User {}>'.format(self.username)

class Post():
    id = db.Column(db.Integer, primary_key=True)
    city = db.Column(db.String(140))
    country = db.Column(db.String(140))
    description = db.Column(db.String(140))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    def __repr__(self):
        return '<Post {}>'.format(self.description)```

Hi! I bet you have already figured this out but it looks like you are on step 10 in the Travel Site project.

You need to complete a few more steps before you add the user_loader. When you complete step 15 you will add the user_loader and the error message should resolve.