views:

42

answers:

2

this is my code in main.py

class marker_data(db.Model):
    geo_pt = db.GeoPtProperty()
class HomePage(BaseRequestHandler):
    def get(self):
        a=marker_data()
        a.geo_pt=db.GeoPt(-34.397, 150.644)
        a.put()
        datas=marker_data.all()
        self.render_template('3.1.html',{'datas':datas})

and in the html is :

    {% for i in datas %}
        console.log(i)
    {% endfor %}

but the error is:

i is not defined

so what can i do ?

thanks

+4  A: 

The 'i' is interpreted by the templating engine on the server side, so you need:

{% for i in datas %}
    console.log({{ i }});
{% endfor %}
sje397
A: 

In addition to the syntax error sje397 mentioned, the .all() method returns a Query object and I think you'll need to call .fetch(n) or .get() on that to retrieve the actual marker_data objects.

datas=marker_data.all().fetch(100)
Peter Gibson
`Query` objects are iterable, and automatically call `fetch()` for you (in batches of 20, I think) behind the scenes when they are iterated over: http://code.google.com/appengine/docs/python/datastore/queryclass.html
Cameron
Oh, good to know - thanks!
Peter Gibson