#24555: Wrong content in inclusion templatetags with variable parent template
-------------------------------------+-------------------------------------
Reporter: benjaminrigaud | Owner: aaugustin
Type: Bug | Status: assigned
Component: Template system | Version: 1.8rc1
Severity: Release blocker | Resolution:
Keywords: templatetags | Triage Stage: Accepted
extends block cache |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by prestontimmons):
The problem here happens on line 1325:
{{{
return self.nodelist.render(new_context)
}}}
Unlike `Template.render`, `NodeList.render` doesn't push the context
stack. Hence, blocks stored in the `render_context` persist where they
should not.
There are a few solutions:
1) Wrap this line in `with new_context.render_context.push():`.
2) Remove the internal `InclusionNode` caching and just call
`t.render(new_context)`.
3) Cache the template object rather than the nodelist and use that.
The easiest solution is to remove internal caching and leave it to the
loaders. That also fixes #23441 that's caused by `InclusionNode` setting
self.nodelist at render time. The downside is a performance regression if
``InclusionNode`` is used in a for loop.
If internal caching is kept, it should be done in the render_context
rather than on the node.
--
Ticket URL: <https://code.djangoproject.com/ticket/24555#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/072.9f226db405e8a4917ce0b90b323016bb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.