[Answered ]-How do I reset template loader cache in Django 1.9?

2👍

Note this question and answer are several years old. At the time it was written, Django did not cache its templates by default. Since then there have been several changes, e.g.

  • Since Django 3.2, templates cached using the cached template loader are correctly reloaded during development.
  • Starting in Django 1.11, Django started caching templates when debug is False.
  • Starting in Django 4.1, Django started caching templates whatever the value of debug.

Here’s my original answer from May 2016:

Django does not cache its templates, but it does cache the list of app template directories used by the app directories loader. If you create a new directory e.g. polls/templates after starting the server, then Django will not pick up templates in this directory until the server has been restarted.

0👍

Really easy:

from django.template.utils import get_app_template_dirs
get_app_template_dirs.cache_clear()

0👍

from django.template.loader import engines

for engine in engines.all():
    engine.engine.template_loaders[0].reset()

Resetting cache for Django cached template loader

Leave a comment