So now, I passed in as dictionary data = { a: a_stuff, b:
b_stuff, ... }
where a_stuff and b_stuff is also a dictionary, a_stuff {a_max:9,
a_min:0, ...... etc}

when i use
{% for key,value in data.items %}
{{key}}, {{value}}
{%endfor%}

it doesn't print anything, but when i do
{% for key in data.items %}{{key}}{%endfor%}

it prints :
('a', {'a_max': 9, 'a_min': 0, .... etc}),

did i pass the data incorrectly or something?

On Aug 24, 12:51 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 8/23/07, *San* <[EMAIL PROTECTED]> wrote:
>
>
>
> > How to add suffix/prefix in a template? So if i passed in a list name-
> > [a,b,c,d] and a_max, b_max, etc from views.py. and I do something like
>
> > {% for i in name %}
> >     {{ i_max}}
> > {% endfor %}
>
> > so I actually wants to print the value of a_max, b_max, etc. Is there
> > a way to do this? or I have to hardcode the code instead of using for
> > loop?
>
> In your example, there's no need to pass in the list of names - you
> are only iterating over the values. However, assuming that you
> actually need the name: If a is related to a_max, then pass in context
> data that expresses that relationship. Don't pass in two disconnected
> lists - pass in a dictionary:
>
> data = { a: a_max, b: b_max, ... }
>
> Then in the template:
>
> {% for key, value in data.items %}
>    {% key %} = {% value %}
> {% endfor %}
>
> 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 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