The dot notation {{answers.answer}} is equivalent to these Python
expressions:
answers['answer']
answers.answer
answers.answer()
you want:
answers[answer]
but the template engine doesn't know that you mean answer to be a
variable rather than a literal.
--Ned.
Todd O'Bryan wrote:
> I'm trying to display the values from a form on a summary page using
> a template. (Actually, I'm trying to do something more complicated,
> but let's start here.) Using {% debug %} I can see that, for example,
>
> answers = { 'a':1, 'b':2, 'c':3 }
>
> and in my template I have
>
> {% for answer in answers.keys %}
> {{answer}} = {{answers.answer}}<br/>
> {% endfor %}
>
> I would expect this to print
>
> a = 1
> b = 2
> c = 3
>
> but I get
>
> a =
> b =
> c =
>
> Am I wrong that the dot notation is supposed to do dictionary lookup
> or is there some other way to do this?
>
> (I'm using m-r 2746.)
>
> Thanks,
> Todd
>
> >
>
>
>
>
--
Ned Batchelder, http://nedbatchelder.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---