diff --git a/ckan/config/middleware/flask_app.py b/ckan/config/middleware/flask_app.py index fa0d4d670df..d5b1ec69c4d 100644 --- a/ckan/config/middleware/flask_app.py +++ b/ckan/config/middleware/flask_app.py @@ -82,6 +82,15 @@ def make_flask_stack(conf, **app_conf): debug = asbool(conf.get('debug', conf.get('DEBUG', False))) testing = asbool(app_conf.get('testing', app_conf.get('TESTING', False))) app = flask_app = CKANFlask(__name__) + # Set jinja_options as soon as possible as it won't affect + # tempaltes in any way after JinjaEnvironment created. It may be + # not obvious, but some of `app` properties are implemented as + # property descriptors, so even assigning can implicitly create + # JinjaEnvironment. + # + # https://flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.jinja_options + app.jinja_options = jinja_extensions.get_jinja_env_options() + app.debug = debug app.testing = testing app.template_folder = os.path.join(root, 'templates')