Skip to content

Commit

Permalink
Preserved context class in inclusion_tag.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aaugustin committed Dec 28, 2014
1 parent fdbfc98 commit e53495b
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions django/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ def compile_func(parser, token):
else:
raise TemplateSyntaxError("Invalid arguments provided to assignment_tag")

def inclusion_tag(self, file_name, context_class=Context, takes_context=False, name=None):
def inclusion_tag(self, file_name, takes_context=False, name=None):
def dec(func):
params, varargs, varkw, defaults = getargspec(func)

Expand All @@ -1277,13 +1277,7 @@ def render(self, context):
else:
t = context.engine.get_template(file_name)
self.nodelist = t.nodelist
new_context = context_class(_dict, **{
'autoescape': context.autoescape,
'current_app': context.current_app,
'use_l10n': context.use_l10n,
'use_tz': context.use_tz,
'engine': context.engine,
})
new_context = context.new(_dict)
# Copy across the CSRF token, if present, because
# inclusion tags are often used for forms, and we need
# instructions for using CSRF protection to be as simple
Expand Down

0 comments on commit e53495b

Please sign in to comment.