I have a module that handles the creation and execution of SQL queries using Jinja2 to render templates. The module itself and the directory called "templates" are located on a network drive, which I can access from several computers on the network.
Everything works when I work from the same directory, as expected.
When I try to download and use this module from a separate place, I get a TemplateNotFound: error. The function itself looks like this: line containing the highlighted error:
from jinja2 import Environment, FileSystemLoader, Template, meta def get_sql_query(position): filename = "PositionDelta.sqltemplate"
This faulty function is the following line:
env = Environment(loader=FileSystemLoader('templates'))
I think when I call the FileSystemLoader function, it looks for the template folder relative to the working folder. How can I set it to search for a template directory relative to the module location itself?
source share