Изменение загрузчика шаблонов django для поддержки темы - это то, что я сделал.
`def load_template_for_user(user, template_name):
"""
Loads a template for a particular user from a theme.
This is used in the generic baseviews and also in the theme template tags
1. First try and load the template with the users theme.
2. Second if that doesn't exist, try and load the template from the default theme
3. Send the template name to the loader to see if we can catch it.
4. With the order of the template loaders, the template loader above will try and
load from the Database.
This will happen if the user tries to use {% extends %} or {% include %} tags
"""
_theme = get_theme_for_user(user)
_theme_template_name = "" + _theme.name + "/templates/" + template_name
# Get the default theme
_default_theme = get_default_theme()
_default_theme_template_name = "" + _default_theme.name + "/templates/" + template_name
_templates=[_theme_template_name, _default_theme_template_name, template_name]
try:
return loader.select_template(_templates)
except TemplateDoesNotExist, e:
log.error("Couldn't load template %s" % template_name)
raise
except Exception, e:
log.error("Couldn't load template, generic Exception %s" % e)
raise
`
Очевидно, что есть некоторый код, который вы не можете видеть, но он в основном выглядитна моделях, чтобы увидеть, что такое default_theme, и get_theme_for_user смотрит на объект UserProfile, чтобы увидеть, для чего они установили свою тему.