Reputation: 501
base.html:
<html>
<body>
{% block content %}
</body>
</html>
child1.html:
{% extends "base.html" %}
{% block content %}
{% block upperDisplay %}
{% endblock %}
child2.html:
{% extends "base.html" %}
{% block content %}
..code for child2 to base
{% end block%}
child11.html (childs for child1):
{% extends "child1.html" %}
{% block upperDisplay %}
..code for child11 to child1
{ %end block% }
Child12:
{% extends "child1.html" %}
{% block upperDisplay %}
<div>
<table>
.... some code ..
</table>
{% block legend %}
<div>
.. some code ..
</div>
{% end block %}
</div>
{% end block %}
Here I wish to use {% block legend %}
also in child1.html, child11.html.
Can you tell me how to do this Django?
Thanks in advance.
Upvotes: 0
Views: 29
Reputation: 11916
Separate that in another file and then include it.
legend_template.html
{% block legend %}
<div>
..some code..
</div>
{% end block %}
Now in other children:
{% include "legend_template.html" %}
Upvotes: 2