Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Jinja caches templates by filename, not by full path. #15

skorokithakis opened this Issue · 2 comments

3 participants


Apparently Jinja uses the template filename in the cache instead of the full pathname. This leads to "index.html", for example, returning the wrong thing if the template loader path has been changed.

If Jinja caches by the whole path (which makes sense, since you're trying to load a specific template), this will work correctly.


Was this issue ever solved? I have the same issue while trying to implement themes with the FileSystemLoader. In my use case, a theme may override a default template but does not need to so my files must be named the same but live in different paths. The paths change per request so a cached home.html in /theme1/ might be valid for User 1 but User 2 should see /theme2/home.html


This issue thread is pretty old, but in case someone is looking for a solution, it looks like 'ChoiceLoader' addresses this use case:

class ChoiceLoader(BaseLoader):
    """This loader works like the `PrefixLoader` just that no prefix is
    specified.  If a template could not be found by one loader the next one
    is tried.

    >>> loader = ChoiceLoader([
    ...     FileSystemLoader('/path/to/user/templates'),
    ...     FileSystemLoader('/path/to/system/templates')
    ... ])

    This is useful if you want to allow users to override builtin templates
    from a different location.

Documented here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.