[Solved]-Django template: Why block in included template can't be overwritten by child template?

13👍

When you include a template, it renders the template, then includes the rendered content.

From the django docs:

The include tag should be considered as an implementation of “render this subtemplate and include the HTML”, not as “parse this subtemplate and include its contents as if it were part of the parent”. This means that there is no shared state between included templates — each include is a completely independent rendering process.

A workaround would be to have the child template extend the included template instead of the including template. Then, include the child template.

Leave a comment