jinja2 load template from string: TypeError: no loader for this environment specified

You can provide loader in Environment from that list

from jinja2 import Environment, BaseLoader

rtemplate = Environment(loader=BaseLoader).from_string(myString)
data = rtemplate.render(**data)

Edit: The problem was with myString, it has {% include 'test.html' %} and Jinja2 has no idea where to get template from.

UPDATE

As @iver56 kindly noted, it’s better to:

rtemplate = Environment(loader=BaseLoader()).from_string(myString)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)