I am trying to get flask-login to work with blueprints and factory, and am not getting it to work (after a lot of searching and trying).
This i how i try to make it work:
bp_home = Blueprint('bp_home', __name__)
bp_waterlevels = Blueprint('bp_waterlevels', __name__)
def create_app():
app = Flask(__name__)
app.register_blueprint(bp_home)
app.register_blueprint(bp_waterlevels)
# Include configuration file handling
configure_app(app)
return app
login_manager = LoginManager()
login_manager.init_app(create_app())
login_manager.login_view = 'login'
@login_manager.user_loader
def load_user(username):
return User(username)
@bp_home.before_request
def before_request():
g.user = current_user
The error i have is :
AttributeError: 'Flask' object has no attribute 'login_manager'
I know it has to do with the load order of the login_manager, but i cannot figure it out.
NOTE : I have seen this ; How do i handle login in flask with multiple blueprints question but it is not working for me. The use of factory gives problems with finding out how to fix the loading order.
Can somebody point me in the right direction, i am kind of stuck ...