Skip to content

Commit e53495b

Browse files
committed
Preserved context class in inclusion_tag.
Previously, when a template was rendered with RequestContext, inclusion tags were rendered with a plain context, losing additional information available in the RequestContext. The (admittedly bizarre) implementation of RequestContext.new() has the side-effect of not running template context processors, making this change backwards-compatible.
1 parent fdbfc98 commit e53495b

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

django/template/base.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ def compile_func(parser, token):
12571257
else:
12581258
raise TemplateSyntaxError("Invalid arguments provided to assignment_tag")
12591259

1260-
def inclusion_tag(self, file_name, context_class=Context, takes_context=False, name=None):
1260+
def inclusion_tag(self, file_name, takes_context=False, name=None):
12611261
def dec(func):
12621262
params, varargs, varkw, defaults = getargspec(func)
12631263

@@ -1277,13 +1277,7 @@ def render(self, context):
12771277
else:
12781278
t = context.engine.get_template(file_name)
12791279
self.nodelist = t.nodelist
1280-
new_context = context_class(_dict, **{
1281-
'autoescape': context.autoescape,
1282-
'current_app': context.current_app,
1283-
'use_l10n': context.use_l10n,
1284-
'use_tz': context.use_tz,
1285-
'engine': context.engine,
1286-
})
1280+
new_context = context.new(_dict)
12871281
# Copy across the CSRF token, if present, because
12881282
# inclusion tags are often used for forms, and we need
12891283
# instructions for using CSRF protection to be as simple

0 commit comments

Comments
 (0)