From ac3c447f5e6fec57338a499c613f8951cf23581c Mon Sep 17 00:00:00 2001 From: Karthik Prabhu Date: Sun, 6 Aug 2017 14:48:21 +0530 Subject: [PATCH] Fix CachedLoader when template_dirs is None From Django 1.10 onwards, `template_dirs` isn't passed while getting the template: https://github.com/django/django/blob/1.10/django/template/engine.py#L155. This causes multi tenant template cache to fail as the cache key is dependent on template_dirs. --- tenant_schemas/template_loaders.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tenant_schemas/template_loaders.py b/tenant_schemas/template_loaders.py index 6224a268..6e966c5c 100644 --- a/tenant_schemas/template_loaders.py +++ b/tenant_schemas/template_loaders.py @@ -38,7 +38,9 @@ def __init__(self, engine, loaders): @staticmethod def cache_key(template_name, template_dirs): - if connection.tenant and template_dirs: + if connection.tenant: + if not template_dirs: + template_dirs = settings.MULTITENANT_TEMPLATE_DIRS return '-'.join([str(connection.tenant.pk), template_name, hashlib.sha1(force_bytes('|'.join(template_dirs))).hexdigest()]) if template_dirs: