开发者

why i can't get the data form Model.all() using google app engine

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


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

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


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜