Putting a block inside another in Django
- by hekevintran
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?