问题描述:

Django's {% include %} and {% ssi %} can render or incorporate a template. But they are designed to process the template and return the HTML. As the docs say "This means that there is no shared state between included templates – each include is a completely independent rendering process."

But what if I want shared context? What if I {% include 'extra/map.html' %} and need to add a block to the <head> section? How can I best break up a large template into parts, and keep the context? The {% include %} mechanism seems potentially much clearer than extending the base, but the context issue gets in the way.

See also Including django templates in other templates so they are actually parsed

相关阅读:
Top