We want one Django
instance to serve different domains. The only difference between them is different templates, all the rest is the same. So we tried to just modify TEMPLATES.DIRS in a middleware
. But Django templates loader ignores all the changes in TEMPLATES.DIRS made after settings.py
is loaded.
Is there more or less standard Django
Way to support different TEMPLATES.DIRS for different domains with just one settings.py
?
To solve your problem use a template variable, both extend
and include
support variables. Just omit the quatation marks:
{% extends "base.html" %}
becomes
{% extends string_variable_with_file_name %}
Of cause you have to set that variable to the right filename in your context.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.