Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我能';t使用google app engine获取数据表单Model.all()_Javascript_Python_Google App Engine - Fatal编程技术网

Javascript 为什么我能';t使用google app engine获取数据表单Model.all()

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

这是我在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
那我该怎么办


谢谢

服务器端的模板引擎会解释“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()