Skip to content Skip to sidebar Skip to footer

Python Import From Parent Directories '__init__.py' File

I am working on a flask app with the following structure: . ├── app │   ├── __init__.py │   ├── forms │   │   └── login.py │   ├──

Solution 1:

You should create the instance of LoginManager out of create_app function. And then you can configure it for login with init_app method.

from flask import Flask
from flask-login import LoginManager

login_manager = LoginManager()

def create_app(config):
    app = Flask(__name__)
    login_manager.init_app(app)
    return app

Post a Comment for "Python Import From Parent Directories '__init__.py' File"