Skip to content

Instantly share code, notes, and snippets.

@xshapira
Created February 25, 2023 08:59
Show Gist options
  • Save xshapira/8341c8bc2fd9add6c6371b80f2919fdf to your computer and use it in GitHub Desktop.
Save xshapira/8341c8bc2fd9add6c6371b80f2919fdf to your computer and use it in GitHub Desktop.
Django 4.1+ -- fix HTML templates not being updated in development.
# Starting with Django 4.1+ we need to pick which template loaders to use
# based on our environment since 4.1+ will cache templates by default.
default_loaders = [
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
]
cached_loaders = [("django.template.loaders.cached.Loader", default_loaders)]
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"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",
],
"loaders": default_loaders if DEBUG else cached_loaders,
},
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment