2 theme
Christian Moser edited this page 2026-10-30 12:09:32 +01:00

DJ-Templates theming

To create a theme you need to create a theme-dictionary or a YAML or JSON file that resolve in a theme-dictionary.

To create a theme dictionary, create a djtt.py in your apps directory and use the variable THEME to point to the dictionary. If the THEME-variable is a string it shall be a relative path pointing to a YAML or JSON file. The starting from the applications directory. If there is no djtt.py file in your app or there is no THEME-variable in the djtt.py, it is searched for a theme.yml, theme.yaml and theme.json file in your apps directory to create the THEME-dictionary.

THEME dictionary

THEME = {
    "theme_name": {
        "extends": "html",  # extend the HTML theme (or your base theme like "bootstrap5")
        "templates": {
            "theme/base": "@theme_name/base",  # link to the theme's base template.
            "theme_name/base": "path/to/your/base/template.html",  # template path
        },
        "static_files": {
            "theme/css":    "@theme_name/css",  # links to the theme's static file
            "theme_name/css": "theme_name/css/theme.css",  # static file path
            "theme_name/theme.js": "theme_name/js/theme.js"  # static file path
            
        },
        "css_files": [
            "@theme_name/css"  # link to static file
            "css/style.css",  # static file path
        ],
        "js_files": [
            "@theme_name/theme.js",  # link to static file
            "js/theme.js",  # static file path
        ],
    },
}