这是我在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})
并且在html中是:
{% for i in datas %}
console.log(i)
{% endfor %}
但错误是:
i is not defined
所以我该怎么办?
感谢
答案 0 :(得分:4)
'i'由服务器端的模板引擎解释,因此您需要:
{% for i in datas %}
console.log({{ i }});
{% endfor %}
答案 1 :(得分:0)
除了提到的语法错误sje397之外,.all()方法还会返回一个Query对象,我认为你需要在其上调用.fetch(n)或.get()来检索实际的marker_data
个对象。
datas=marker_data.all().fetch(100)