title: I am trying to learn Flask, but UserMixin seems not to work
body: <p>So to be more exact. I am currently learning Flask from <a href="https://www.youtube.com/watch?v=MwZwr5Tvyxo&amp;list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH" rel="nofollow noreferrer"><strong>Corey Schafers</strong></a> tutorial series and I am in the phase of Login Authentication, everything seemed to be fine, but then I got this error after trying to log in:</p>
  
  <pre><code>AttributeError
  AttributeError: 'User' object has no attribute 'is_active'
  
  Traceback (most recent call last)
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 2463, in __call__
  return self.wsgi_app(environ, start_response)
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 2449, in wsgi_app
  response = self.handle_exception(e)
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 1866, in handle_exception
  reraise(exc_type, exc_value, tb)
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\_compat.py", line 39, in reraise
  raise value
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 2446, in wsgi_app
  response = self.full_dispatch_request()
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
  rv = self.handle_user_exception(e)
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 1820, in handle_user_exception
  reraise(exc_type, exc_value, tb)
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\_compat.py", line 39, in reraise
  raise value
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
  rv = self.dispatch_request()
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 1935, in dispatch_request
  return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\panda\Desktop\HDD\Documents\Code\Python\Flask\flaskblog\routes.py", line 60, in login
  login_user(user, remember=form.remember.data)
  File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask_login\utils.py", line 158, in login_user
  if not force and not user.is_active:
  </code></pre>
  
  <p>My code where the class User is defined looks like this:</p>
  
  <pre><code>from datetime import datetime
  from flaskblog import db, login_manager
  from flask_login import UserMixin
  
  
  
  @login_manager.user_loader
  def load_user(user_id):
      return User.query.get(int(user_id))
  
  
  class User(UserMixin, db.Model):
      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}')"
  </code></pre>
  
  <p>My <strong>init</strong>.py file looks like this:</p>
  
  <pre><code>from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from flask_bcrypt import Bcrypt
  from flask_login import LoginManager
  
  app = Flask(__name__)
  app.secret_key = '5791628bb0b13ce0c676dfde280ba245'
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
  db = SQLAlchemy(app)
  login_manager = LoginManager(app)
  
  
  bcrypt = Bcrypt(app)
  from flaskblog import routes
  </code></pre>
  
  <p>My code with route to the login page looks like this:</p>
  
  <pre><code>from flaskblog.models import User, Post
  from flask import render_template, url_for, flash, redirect
  from flaskblog.forms import RegistrationForm, LoginForm
  from flaskblog import app, db, bcrypt
  from flask_login import login_user
  
  @app.route("/login", methods=['GET', 'POST'])
  def login():
  
      form = LoginForm()
      if form.validate_on_submit():
          user = User.query.filter_by(email=form.email.data).first()
          if user and bcrypt.check_password_hash(user.password, form.password.data):
              login_user(user, remember=form.remember.data)
              return redirect(url_for('home'))
          else:
              flash('Login Unsuccessful. Please check email and password', 'danger')
      return render_template('login.html', title='Login', form=form)
  </code></pre>
  
  <p>The weirdest part is that even in the case that <strong>I edit the class User so that it contains the method "is_active" in itself</strong>, the error <strong>keeps on appearing</strong>.</p>
  
  <pre><code>from datetime import datetime
  from flaskblog import db, login_manager
  from flask_login import UserMixin
  
  
  
  @login_manager.user_loader
  def load_user(user_id):
      return User.query.get(int(user_id))
  
  
  class User(UserMixin, db.Model):
  
  
      def is_active():
          return True
  
  
      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}')"
  </code></pre>
  
  <p>Also, the same problem happens on multiple operating systems on multiple computers, if that is helpful.</p>