On 5/4/06, Eric Walstad <[EMAIL PROTECTED]> wrote:
>
> Is it possible to iterate over a dictionary in a django template, displaying
> the dictionary values, without knowing the dictionary's keys beforehand?
>
> I want to simply list keys and values of a dictionary passed into a template,
> but I haven't been able to figure out how.
>
> I'd like to do something like:
> {% for err in errors %}
>     {{ errors.err }}
> { % end for %}
>
> In pure python I could do:
> plotz = {'foo':'bar', 'fizz':'bang'}
> for frob in plotz:
>     print frob
>
> foo
> fizz
>
> I've been able to do this in the template, but I can't get the following to
> work in a template:
>
> for frob in plotz:
>     print plotz[frob]
>
> bar
> bang
>

{% for i in plotz.items %}
    Key  {{ i.0 }}
    Value  {{ i.1 }}
{% endfor %}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to