How do you insert a template into another template?

You can do:

<div class="basic">
{% include "main/includes/subtemplate.html" %}    
</div>

where subtemplate.html is another Django template. In this subtemplate.html you can put the HTML that would be obtained with Ajax.

You can also include the template multiple times:

<div class="basic">
{% for item in items %}
    {% include "main/includes/subtemplate.html" %}    
{% endfor %}
</div>

Leave a Comment