jinja
jinja copied to clipboard
Overriding blueprint template does not take effect until restart
Overriding a blueprint's template does not take effect without restarting the development server.
Follow these steps to reproduce:
- First, add and register the following blueprint without creating any templates. It should produce a "Template Not Found" error:
from flask import Blueprint, render_template
blueprint = Blueprint(
'blueprint',
__name__,
template_folder='blueprint/templates')
@blueprint.route('/testoverride')
def TestOverride():
return render_template('test.html')
- Next, add a new template called "test.html" under the blueprint's template directory and refresh the page. It should find the template without restarting the server.
- Now add a second template having the same filename but different content under the application's template directory and refresh the page. The page's content will not change without restarting the server.
- Restart the server and refresh the page. Confirm the content has now changed.
This is tricky to do because of how the loaders work. For development purposes I would recommend disabling the template cache until this is properly fixed.