Table of Contents
DJ Templates Configuration
setup.py
BASE_TEMPLATE
This is the base template that is used for all templates.
This is the global override for the base template.
If the base template starts with a dollar sign $, it will be replaced with the base template name for the current theme. If it starts with a @, it will be replaced with the base template name for the current theme, but it will be searched in the theme's templates directory. Else it will be treated as a normal django template name and will be searched in the default templates directories.
DJ_TEMPLATES
DJ_TEMPLATES is a dictionary that defines the templates and static files for each theme. This is the global override for the themes.
The keys of the dictionary are the theme names, and the values are dictionaries that define the templates and static files for that theme.
FAVICON
FAVICON is the path to the favicon that is used for all templates. This is the global override for the favicon and is used by themes that support it.
THEME
THEME is the default theme name that is used for all templates. defaults to html if not set in settings.py
THEME_FUNCTION
THEME_FUNCTION is a callable that takes a request and returns the theme string.
This allows you to load the theme dynamically based on the request, for example, based on the user or other request parameters.
Here an example function that returns the theme based on the user.
def get_theme(request):
from dj_templates import settings as templates_settings
if request.user.is_authenticated:
# If the user is authenticated, return the theme based on the
# user's preference (assuming the user has a profile with a
# theme attribute)
return request.user.profile.theme
else:
## If the user is not authenticated, return the default theme
return templates_settings.THEME
Content
Django Templates © 2026 Christian Moser - All rights reserved. - BSD 1-Clause License