Let's say there are base_a.html
, base_b.html
, a.html
, b.html
, c.html
.
a.html
extends base_a.html
and b.html
extends base_b.html
.
And c.html
has to extend both base_a.html
and base_b.html
.
It will be easier to understand this situation if you think base_a.html
contains reply functionalities and base_b.html
contains search functionalities.
Can I use multiple inheritance in Django template?
Or do I have to use include instead of extends?
As stated at the docs,
That suggests that an
{% extends %}
tag cannot be placed in the second line, that is, you cannot have two{% extends %}
tags.Your case can easily be solved with
{% include %}
tags. For example:In
a.html
:In
b.html
:In
c.html
:Of course,
base_a.html
andbase_b.html
should only contain the specific block you want to reuse, not a full HTML template.