Hello all,
I'd like to open a discussion on the Loader Template (django/template/loaders/app_directories.py)
which is linked to the Template Engine (django/template/engine.py) about
the context it has when determining the templates to load.
## Use Case
In order to do multi-tenancy on our project, we set the current_site on
the input request in a middleware (almost the same as
django/contrib/sites/middleware.py).
Then our part of the system base its computation on the current_site of
the request.
Some of our clients needs to have specific markup template (.html
template).
In order to do that, we chose a hierarchy of templates, that can be
overriden if we have another folder with the same name of the
client/website.
Let's take an example:
We have as templates:
- /default/base.html
- /custom/base.html
If the request.site is named "custom", then we want to load the
/custom/base.html . Otherwise we load the /default/base.html
## Problem encounter
The Loader for the template doesn't have any context, and so we have
setup a global state with the request in threads local. I personnaly
hate global state in Django
(
https://code.djangoproject.com/wiki/GlobalState).
## Proposal
I'd like to know if we could add the possibility to have more context on
the Loader? At least the request?
This is a bit of refacto in the code of Django as the Engine is created
only once for every Django process.
Thanks for your reading,
Have a good day