Your HTML template for loop expects a list. But you try to pass a
dictionary.

You mustn't mix up the Python terms 'list' / 'tuple' and 'dictionary'
- see:
http://www.sthurlow.com/python/lesson06/

List values are defined within sqare brackets. If they are immutable
(unchangable) they are called 'tuple' and its values are defined
within rounded brackets. Thus a list may be defined by:
myList = [ 'name1', 'name2']

Dictionary key-value pairs are defined within curly brackets.  For
example by
myDictionary = { 'a':'1', 'b':'2' }
To return a single value you must add the key within square brackets:
myDictionary['b'] will return '2'
To return the whole list of dictionary keys use the keys() function:
myDictionary.keys() will return the list  [ 'a', 'b' ]
To return the whole list of dictionary values use the values()
function:
myDictionary.values() will return the list [ '1', '2' ]


Try the following:
------------ In Python:
myDictionary = { 'a':'1', 'b':'2' }
listOfmyDictionaryValues= myDictionary.values()
listOfmyDictonaryKeys = myDictionary.keys()

template_values = {
      'keyList': listOfmyDictonaryKeys,
      'valueList': listOfmyDictonaryValues,
      }

------------ In Template:
> {% for keyXYZ  in keyList %}
>   {{keyXYZ}}
> {%endfor%}
> {% for valueXYZ  in valueList %}
>   {{valueXYZ}}
> {%endfor%}

------------
This way the dictionary 'template_values' containing the lists
'listOfmyDictonaryKeys' and 'listOfmyDictonaryValues'  is passed from
Python to the Template.

---------------
Attention:
Don't mix up definig equations with square brackets for lists and
curly brackets for dictionares after the equal sign with the
constructor method with rounded brackets behind the constructor name
and no equal sign.

And don't mix up this Python term of 'dictionary keys' with the
appengine term of datastore 'Entitiy keys'.


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

Reply via email to