I need to output objects in Django template, so that each object has its own template. Templates are keeped in the variable “templates” like that – [‘path/to/template1′,’path/to/template2’, …]
Is there a way to “cycle” these templates in object loop, somehow like that:
{% for object in objects %}
{% cycle templates as template %}
{% include template %} // this code is just for example
{% endfor %}
I cannot include these templates directly into objects list, because it is generated by paginator’s template tag.
Any ideas? Thanks.
I’ve written the template tag that receives a list variable and cycles it through the loop.
It’s pretty simple but solves the issue.