From 078273eb7db5a481a4131d44a943f3c9e34b6b88 Mon Sep 17 00:00:00 2001 From: Parker Berberian Date: Thu, 30 Jan 2020 13:33:35 -0500 Subject: Adds Template Overrides Changes the structure of the template directories to allow a new project to define their own set of override templates that inherit from a common base. I have slightly modified landing.html here as an example. In comming changes we will try to move all the "laas" specific content into the laas directory Change-Id: I46151be182de901f870debb247b305ea34ae77ba Signed-off-by: Parker Berberian --- src/laas_dashboard/settings.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/laas_dashboard/settings.py') diff --git a/src/laas_dashboard/settings.py b/src/laas_dashboard/settings.py index 951ce1a..d41ad0c 100644 --- a/src/laas_dashboard/settings.py +++ b/src/laas_dashboard/settings.py @@ -53,10 +53,23 @@ MIDDLEWARE = [ ROOT_URLCONF = 'laas_dashboard.urls' +TEMPLATE_OVERRIDE = os.environ.get("TEMPLATE_OVERRIDE_DIR", "") # the user's custom template dir +TEMPLATE_DIRS = ["base"] # where all the base templates are + +# If the user has a custom template directory, +# We should search that first. Then we search the +# root template directory so that we can extend the base +# templates within the custom template dir. +if TEMPLATE_OVERRIDE: + TEMPLATE_DIRS = [TEMPLATE_OVERRIDE, ""] + TEMPLATE_DIRS + +# all template dirs are relative to /project_root/templates/ +dirs = [os.path.join(BASE_DIR, "templates", d) for d in TEMPLATE_DIRS] + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'DIRS': dirs, 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ -- cgit 1.2.3-korg