Re: django- accessing items in a python dictionary
On Sunday, April 29, 2012 7:36:17 AM UTC-7, hius...@qq.com wrote: what is value of the etc? > I believe that etc. in this case is an abbreviation for etcetera. -- 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/-/CupTM1pXfVoJ. To post to this group, send email to django-users@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.
Re: django- accessing items in a python dictionary
On Sun, Apr 29, 2012 at 6:01 AM, Alan Mowrote: > 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 What version of Django are you using? This particular error message was removed from Django five years ago (before Django 1.0): https://code.djangoproject.com/changeset/5443 (not-so-coincidentally when the support for iterating over dictionary items like you are trying was added). If you are changing and old project you'll need to stick to docs from the version of Django you have, or upgrade the project. If you are just starting out you should definitely delete whatever Django you have installed and start with 1.4 instead. Karen -- http://tracey.org/kmt/ -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django- accessing items in a python dictionary
what is value of the etc? 2012/4/29 Alan Mo <mrmo...@gmail.com>: > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.