Thanks for hint!
This is exactly, what I need.
Example for others:
{%- for item in items recursive %}
<li><a href="{% url url_name item.pk %}">{{ item.name }}</a></li>
{%- if not item.is_leaf_node() -%}
<ul class="submenu">{{ loop(item.get_children()) }}</ul>
{%- endif %}</li>
{%- endfor %}
items variable is loaded in view like this:
ItemModel.objects.filter(level=0), for complete tree.
Martin
Dne úterý, 6. listopadu 2012 14:28:51 UTC+1 Simon Sapin napsal(a):
>
> Le 06/11/2012 14:05, Martin Kub�t a �crit :
> > In django exist project "django-mptt" with has a "recursetree" tag
> > (http://django-mptt.github.com/django-mptt/templates.html#recursetree).
> > Is something similar for jinja2?
>
> for-loops in Jinja2 can be "recursive":
> http://jinja.pocoo.org/docs/templates/#for
>
> Is that what you need?
>
> --
> Simon Sapin
>
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pocoo-libs/-/LN3xsIKRD6MJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.