fix: email templates caching (#32627)

This commit is contained in:
Dmytro
2024-03-21 14:37:44 +01:00
committed by GitHub
parent 09cb944801
commit d19bd263c4

View File

@@ -27,13 +27,17 @@ class ThemeFilesystemLoader(FilesystemLoader):
is_usable = True
_accepts_engine_in_init = True
def __init__(self, engine, dirs=None):
if not dirs:
self.dirs = engine.dirs
def get_dirs(self):
"""
Override get_dirs method.
Make the theme templates a priority, avoiding cashing templates for django ones.
"""
dirs = super().get_dirs()
theme_dirs = self.get_theme_template_sources()
if isinstance(theme_dirs, list):
self.dirs = theme_dirs + self.dirs
super().__init__(engine, self.dirs)
if theme_dirs:
dirs = theme_dirs + dirs
return dirs
@staticmethod
def get_theme_template_sources():