Ticket #12095: 12095.diff

File 12095.diff, 1.2 KB (added by Luke Plant, 15 years ago)

Patch for inclusion tag.

  • django/template/__init__.py

     
    942942                        else:
    943943                            t = get_template(file_name)
    944944                        self.nodelist = t.nodelist
    945                     return self.nodelist.render(context_class(dict,
    946                             autoescape=context.autoescape))
     945                    new_context = context_class(dict, autoescape=context.autoescape)
     946                    # Copy across the CSRF token, if present, because inclusion
     947                    # tags are often used for forms, and we need instructions
     948                    # for using CSRF protection to be as simple as possible.
     949                    csrf_token = context.get('csrf_token', None)
     950                    if csrf_token is not None:
     951                        new_context['csrf_token'] = csrf_token
     952                    return self.nodelist.render(new_context)
    947953
    948954            compile_func = curry(generic_tag_compiler, params, defaults, getattr(func, "_decorated_function", func).__name__, InclusionNode)
    949955            compile_func.__doc__ = func.__doc__
Back to Top