我对Flask shell有问题。
File "/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/sitebuild/site.py", line 6, in <module>
@app.shell_context_processor
AttributeError: 'NoneType' object has no attribute 'shell_context_processor'
我已经在.env,.flaskenv中甚至通过导出手动设置了环境变量。
site.py包含
from app import create_app, db
from app.models import User, Post
app = create_app()
@app.shell_context_processor
def make_shell_context():
return {'app': app, 'db': db, 'User': User, 'Post': Post}
和主要的 init 具有create_app函数-
def create_app(config_class=Config):
app = Flask(__name__, static_url_path='/static')
app.config.from_object(config_class)
db.init_app(app)
migrate.init_app(app, db)
login.init_app(app)
mail.init_app(app)
bootstrap.init_app(app)
moment.init_app(app)
return app
任何想法,我都出去了,网上看不到任何东西。