Javascript 为什么我能';t使用google app engine获取数据表单Model.all()
这是我在main.py中的代码Javascript 为什么我能';t使用google app engine获取数据表单Model.all(),javascript,python,google-app-engine,Javascript,Python,Google App Engine,这是我在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()
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
那我该怎么办
谢谢服务器端的模板引擎会解释“i”,因此您需要:
{% for i in datas %}
console.log({{ i }});
{% endfor %}
“i”由服务器端的模板引擎解释,因此您需要:
{% for i in datas %}
console.log({{ i }});
{% endfor %}
除了前面提到的语法错误sje397外,.all()方法还返回一个对象,我认为您需要对其调用.fetch(n)或.get()来检索实际的
标记_数据
对象
datas=marker_data.all().fetch(100)
除了前面提到的语法错误sje397外,.all()方法还返回一个对象,我认为您需要对其调用.fetch(n)或.get()来检索实际的
标记_数据
对象
datas=marker_data.all().fetch(100)
Query
对象是可iterable的,迭代时会在后台自动调用fetch()
:Query
对象是可iterable的,迭代时会在后台自动调用fetch()
: