title: Flask-Login extension fail to register, login Manager not defined
body: <p>I am facing an issue where my app is not able to recognise '@login_manager' decorator even though I have imported login_manager object created from extensions.py. I tried to debug the issue by printing out the package extensions that are configured in the app and it seems that login_manager is not included. Maybe that could be the cause of the failure. I have also read through <a href="https://stackoverflow.com/questions/43545133/flask-extension-not-registered-in-app-extensions">this</a> posted question, but I felt it wasn't a satisfying answer. Given that login_manager.init(app), is recommended in the official documentation found <a href="https://flask-login.readthedocs.io/en/latest/" rel="nofollow noreferrer">here</a>.</p>
  <p>Hope someone who is really experience in flask to be able to help me out here. Thank you!</p>
  <p>app.py</p>
  <pre><code>from flask_login import login_required, current_user
  from flask import Flask, render_template,request
  from amazonreviews import main_func as m
  import os
  import json
  
  def create_app():
     app = Flask(__name__)
     with app.app_context():
          app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://///somepath/abc.sqlite3'
          app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
          app.secret_key = os.urandom(24)
  
          #Initialise extensions
          register_extensions(app)
  
          return app
  
  def register_extensions(app):
          from extensions import db
          from extensions import migrate
          from extensions import login_manager
  
          db.init_app(app)
          migrate.init_app(app,db)
          login_manager.init_app(app)
  
          for key in app.extensions:
              print(key)
  
  app = create_app()
  #A user loader tells Flask-Login how to find a specific user from the ID that is stored in      their session cookie
  
  @login_manager.user_loader
  def load_user(user_id):
          from model import User
          # since the user_id is just the primary key of our user table, use it in the query for the user
          return User.query.get(int(user_id))
  </code></pre>
  <p>extensions.py</p>
  <pre><code>#Import external packages and create external objects
  from flask_sqlalchemy import SQLAlchemy
  from flask_login import LoginManager
  from flask_migrate import Migrate
  
  
  migrate = Migrate()
  db = SQLAlchemy()
  login_manager = LoginManager()
  </code></pre>
  <p>Print key from extension output:
  <a href="https://i.stack.imgur.com/lM307.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lM307.png" alt="Print key output" /></a></p>
  <p>@login_manager decorator not recognised:
  <a href="https://i.stack.imgur.com/ApMyR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ApMyR.png" alt="enter image description here" /></a></p>