-
-
Notifications
You must be signed in to change notification settings - Fork 16.8k
Method render_template does not use blueprint specified template_folder #1361
Copy link
Copy link
Closed
Labels
Description
- File structure:
project -
- templates \
- a \
search.html
- b \
search.html
- start.py
- myapplication \
- test.py
- Start file:
# start.py
from flask import Flask
from myapplication.test import test_blueprint
app = Flask(__name__)
app.register_blueprint(test_blueprint)
- my application
# test.py
from flask import Blueprint, render_template, abort
from jinja2 import TemplateNotFound
test_blueprint = Blueprint('test_blueprint', __name__,
template_folder='absolute_path_to_project/templates/a')
# YES, I specified the absolute path to the template a
@test_blueprint.route('/test')
def show():
try:
return render_template(''search.html") # HERE is the problem
except TemplateNotFound:
abort(404)
Is this a problem?
# Actually, I want to render a/search.html
# But, render_template() does not use test_blueprint's template_folder
# render_template() search the template list, find the first search.html, then render
# So, maybe render a/search.html or b/search.html
# This depend on the sequence of the template list
Reactions are currently unavailable