I could be completely mistaken, but can't you replace 'post.0.title'
and 'post.0.post' with 'x.title' and 'x.post', respectively?

On Jun 17, 1:50 pm, "Juan Hernandez" <[EMAIL PROTECTED]> wrote:
> Hey there
>
> I've been practicing for a while with the template system and I have some
> questions:
>
> Lets say that I create this dictionary:
>
> test = dict()
> test[0] = {'title': 'My First Title', 'post': 'My First Post'}
> test[1] = {'title': 'My Second Title', 'post': 'My Second Post'}
> etc... til 10 for example
>
> If i want to display that information, the best way would be to iterate over
> each number and show 'title' and 'post'.
>
> My question is: How can I actually iterate over a dictionary like this
> inside a template? If i do this (assuming that the shown dictionary has been
> assigned to 'post' in render_to_response)
>
> {% for x in post%}
> <h2><a href="#">{{ post.0.title }}</a></h2>^M
> <br>
> <br>
>        <p>{{ post.0.post }}</p>^M
>
> It will only show the first part of the dictionary and 'x' as a number
> cannot be handled. I haven't found a way to have an increasing number to
> iterate with... Something to replace the zero that increases until is
> finished by hte condition
>
> What would be the best way to display the whole dictionary in a template??
>
> Thank you very much as usual
> jhv
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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