问题
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