Putting a block inside another in Django
Posted
by hekevintran
on Stack Overflow
See other posts from Stack Overflow
or by hekevintran
Published on 2010-03-13T03:11:33Z
Indexed on
2010/03/13
3:17 UTC
Read the original article
Hit count: 356
I have a Django template that I want to extend in multiple places. In some the div must be inside a form, and in others it must not be. To do this I put a block above and below the div so I could add and in them respectively.
Desired:
<form>
<div class="my_div">
{% block div_content %}
...
{% endblock %}
</div>
</form>
Template:
{% block div_top %}{% endblock %}
<div class="my_div">
{% block div_content %}
{% endblock %}
</div>
{% block div_bottom %}{% endblock %}
Looking at this I can't help but think that there is a better way to do it. What is the standard Django way of doing this?
© Stack Overflow or respective owner