From 94a180402c9e52bca2e911b6427c88f436e95449 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Wed, 28 Feb 2018 16:12:50 +0100 Subject: [PATCH] Refs #27728 -- Fixed thread safety of admin template tags. Regression in 5cc28dc752c3ae78456bb835c3ba195489fc26d7. --- django/contrib/admin/templatetags/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/templatetags/base.py b/django/contrib/admin/templatetags/base.py index 2d261c0e88..ec6f10378d 100644 --- a/django/contrib/admin/templatetags/base.py +++ b/django/contrib/admin/templatetags/base.py @@ -23,10 +23,11 @@ class InclusionAdminNode(InclusionNode): opts = context['opts'] app_label = opts.app_label.lower() object_name = opts.object_name.lower() - self.filename = [ + # Load template for this render call. (Setting self.filename isn't + # thread-safe.) + context.render_context[self] = context.template.engine.select_template([ 'admin/%s/%s/%s' % (app_label, object_name, self.template_name), 'admin/%s/%s' % (app_label, self.template_name), 'admin/%s' % (self.template_name,), - ] - + ]) return super().render(context)