On Feb 5, 9:02 am, harryos <oswald.ha...@gmail.com> wrote:
> hi
> I have a dictionary object passed to the template , from which I need
> to retrieve values
>
> mydata={}
> mydict['chemistry']=120
> mydict['physics']=164
> mydict['maths']=110
>
> In my render_to_response I passed this object like
> return render_to_response("myapp/mydatapage.html",
> {'mydata_dict':mydata})
>
> I need to show this data on the page as
>
> chemistry=120
> physics=164
> math=110
>
> On the template html, I tried this
>
> {% for key in mydata_dict %}
> {{key}} ={{ mydata_dict[key] }}
>
> {% endfor %}
>
> This gives TemplateSyntaxError :Could not parse the remainder: '[key]'
> from 'mydata_dict[key]'
>
> I understand template doesn't allow [] operator..Can somebody tell me
> how I can get the value corresponding to the key?
>
> thanks
> harry
> How else

Seriously, did you try reading the documentation before asking this
question? Or searching the group? This is a very frequently asked
question.

http://docs.djangoproject.com/en/1.1/topics/templates/#variables
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to