Sunday, April 29, 2012

django- accessing items in a python dictionary

My dictionary is as follows:

data={"BE1234":"abc", "BA3212":"efg", etc}

I call it through django templates. According to the online manual, they say "if your context contained a dictionary data, the following would display the keys and values of the dictionary":

{% for key, value in data.items %}
{{ key }}: {{ value }}
{% endfor %}

I get the error: TemplateSyntaxError: 'for' statements with five words should end in 'reversed': for key, value in data.items

Can anyone help me fix this error? It's really frustrating. Just wondering if I'm doing something stupid. Thanks in advance.


posted on stackoverflow: http://stackoverflow.com/questions/10371168/django-accessing-items-in-a-python-dictionary

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

No comments:

Post a Comment