Closed
Description
Any HTML files in the templates/
directory under the project root are not being picked up. This is likely due to my custom setup, where the settings files are nested deeper in the directory structure than usual.
project_root/
templates/
base/
not_pickedup.html
config/
django/
base_settings.py
dev.py
prod.py
accounts/
templates/
picked_up.html
To resolve this, add
BASE_DIR / "templates"
to your TEMPLATES
setting to force it:
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent.parent
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
BASE_DIR / "templates",
],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
Metadata
Metadata
Assignees
Labels
No labels