[Django]-Django: How do you avoid polluting the parent context in an inclusion tag?

3👍

I think you need something like this:

new_context = {'page_url': url}
new_context.update(context)
return new_context

Hope this helps

1👍

Before updating the existing context, push() it onto the stack. After having rendered your template with a modified context, pop() it to restore the previous values.

This is documented here.

👤jrief

Leave a comment