My studying notebook

2009/05/08

App Engine TemplateSyntaxError

5/08/2009 06:17:00 AM Posted by Unknown , 5 comments
from google.appengine.ext.webapp import template

def HtmlRender(self, template_file, template_values):
temp = os.path.join(os.path.dirname(__file__),
'templates/'+template_file)
self.response.out.write( template.render(temp, template_values) )


template_values ={
'url' : self.request.url,
'my_dictionary' : { 'item1' : 1, 'item2' : 2}
}


url: {{ url }}
{% for key, value in my_dictionary.items %}
{{ item.key }} : {{ item.value }}
{% endfor %}


As you can see above code. you can app engine template to generate HTML than before generate code from within strings in the Python..

"TemplateSyntaxError: 'for' statements with five words should end in 'reversed': for key, value in my_dictionary.items".

Yes, you will get one error message. What? It looks as normal python code and seems does work. Because Google App Engine now support Django 0.96 version. If you want to receive a dictionary data type from python. You must modify Django template in HTML page.


more detail information:

5 comments:

  1. Gaining Python certifications will validate your skills and advance your career.
    python certification

    ReplyDelete
  2. All of pitbull dog and puppy are sent home. Current on shots, deworming, flea treated, health certificate, genetic health guarantee, and AKC registration papers. All new families are required to sign a contract that includes a basic health guarantee and a 3 year genetic health guarantee.
    Pitbull Puppies For Sale
    american pitbull terrier puppies
    pitbull puppies for sale near me
    pitbull breeders for sale
    pit bull breeders near me
    pit bull puppy
    baby pitbulls for sale

    ReplyDelete