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