jinja2.exceptions.TemplateNotFound: bootstrap/base.html

社会主义新天地 提交于 2019-12-23 10:54:32

问题


I'm inheriting bootstrap/base.html in a Flask application after installing the Bootstrap Flask extension but having the below error:

jinja2.exceptions.TemplateNotFound: bootstrap/base.html

回答1:


You need to import Bootstrap in this way below:

from flask_bootstrap import Bootstrap
...
bootstrap = Bootstrap(app)

flask.ext.bootstrap is deprecated




回答2:


Need to import Bootstrap from flask.ext.bootstrap and bootstrap the flask app as below:

from flask.ext.bootstrap import Bootstrap
...
bootstrap = Bootstrap(app)



回答3:


The answer is correct.

You can test settings in the execution file, for example: flaskr/flaskr.py

from flask_bootstrap import Bootstrap
....
app = Flask(__name__)
bootstrap = Bootstrap(app)
db = SQLAlchemy(app)

The problem should have been solved.




回答4:


If it's a full flask project, u need to do these:

from flask_bootstrap import Bootstrap
bootstrap = Bootstrap(app)

inside your __init__.py file



来源:https://stackoverflow.com/questions/44318142/jinja2-exceptions-templatenotfound-bootstrap-base-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!