techwithtim / Flask-Web-App-Tutorial

Code for the note storing flask web app made during a YouTube video.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'Flask' object has no attribute 'login_manager'

Metior21 opened this issue · comments

Traceback (most recent call last):
File "c:\Users\x\Desktop\Flask-Web-App-Tutorial-main\main.py", line 3, in
app = create_app()
File "c:\Users\x\Desktop\Flask-Web-App-Tutorial-main\website_init_.py", line 15, in create_app
from .views import views
File "c:\Users\x\Desktop\Flask-Web-App-Tutorial-main\website\views.py", line 2, in
from flask_login import login_required, current_user
File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_login_init_.py", line 12, in
from .login_manager import LoginManager
File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_login\login_manager.py", line 33, in
from .utils import _create_identifier
File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_login\utils.py", line 23, in
login_manager.init_app(app)
NameError: name 'login_manager' is not defined

I've tried following solution but it still gave the same error.

https://stackoverflow.com/questions/31067249/attributeerror-flask-object-has-no-attribute-login-manager-login-manager

same here? any solution?

ANY SOLUTIONS??/

I think that under db.init_app(app) in the init.py file
The following lines need to be added:
login_manager = LoginManager() login_manager.login_view = 'auth.login' login_manager.init_app(app)
as well as a decorator function (I am not sure about it)
please refer to https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login