Using the template tag with , I could make a tree / recursive list.
Code example:
Basic pattern: it is assumed that "all_root_elems" is a list of one or more tree roots
<ul> {%for node in all_root_elems %} {%include "tree_view_template.html" %} {%endfor%} </ul>
tree_view_template.html displays the nested ul , li and uses the node template variable, as shown below:
<li> {{node.name}} {%if node.has_childs %} <ul> {%for ch in node.all_childs %} {%with node=ch template_name="tree_view_template.html" %} {%include template_name%} {%endwith%} {%endfor%} </ul> {%endif%} </li>
Rohan Jul 25 '12 at 7:21 2012-07-25 07:21
source share