On 1/16/07, fiedzia <[EMAIL PROTECTED]> wrote:

Looking for a way to handle nested dicts within templates I've found
following syntax to work:


% for cat in songs.items %}
        {% for author in cat.1.items %}
                {% for song in author.1.items %}
                        ...
but I can't find any documentation for that, so the question is:

is it a hack or oficially suported syntax
and where should i look for documentation
(or who ask to mention it there)

This is a supported syntax; another approach would be:

% for cat in songs.values %}
       {% for author in cat.values %}
               {% for song in author.values %}

Neither of these approaches are explictly documented - they just
exploit the lookup variable mechanism, which is documented here:

http://www.djangoproject.com/documentation/templates/#variables

In your template snippet, song.items() returns tuples, which means
that cat[1] returns the value at list index 1. My example uses
song.values() to just return the value (since that is all you are
using). Pick the strategy that is right for you.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to