On Wed, Mar 18, 2009 at 4:49 PM, Jason Wang <[email protected]> wrote:
>
> Hi all,
>
> I have a problem where i have a list which stores a bunch of relevant
> key to another dictionary. I want to loop through the list and print
> out the information contained in the keys to output.
>
> Apparently it doesn't work.
>
> So for example i have the following:
>
> lst = ["a", "b"]
> dic = {"a":1, "b":2, "c":3}
>
> I wish to print out 1 and 2 but not 3.
>
> If i do the following, it doesn't work:
> {% for t in lst %}
> {{ dic.t}}
> {% endfor %}
>
> Does anyone have any suggestions on how to accomplish this?
>
> Thanks a lot!
>
> >
>
Write a template filter that does the lookup against the variable.
Alex
--
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---