Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Flask登录模块';app&x27;没有属性';请求后';_Python_Flask_Flask Login - Fatal编程技术网

Python Flask登录模块';app&x27;没有属性';请求后';

Python Flask登录模块';app&x27;没有属性';请求后';,python,flask,flask-login,Python,Flask,Flask Login,我正在尝试将Flask登录与Flask一起使用,但是当我尝试使用app()初始化LoginManager类时,出现以下错误: AttributeError: module 'app' has no attribute 'after_request' 以下是我的代码片段: 从flask\u登录导入登录管理器 login\u manager=LoginManager() ... def create_app(): 从烧瓶进口烧瓶 app=烧瓶(名称) ... 登录管理器。初始化应用程序(应用程序)

我正在尝试将Flask登录与Flask一起使用,但是当我尝试使用app()初始化
LoginManager
类时,出现以下错误:

AttributeError: module 'app' has no attribute 'after_request'
以下是我的代码片段:

从flask\u登录导入登录管理器
login\u manager=LoginManager()
...
def create_app():
从烧瓶进口烧瓶
app=烧瓶(名称)
...
登录管理器。初始化应用程序(应用程序)

我真的不知道我做错了什么。

好的,所以我找出了问题的原因。在
init_app
行之前,我导入了我的模型(用于Flask Migrate),如下所示:

import app.models.<model-name-here>
导入app.models。
我把它改成了

from app.models.<model-name-here> import <model-name-here>
来自app.models的
。进口
我仍然不知道为什么会出现问题,但现在它起作用了