无法过滤非节点参数 - 数据存储区 - 谷歌应用程序引擎 - python

时间:2013-11-01 03:01:44

标签: python google-app-engine google-cloud-datastore

Class user(ndb.Model):
  def post(self):
    name = db.StringProperty()
    age = db.StringProperty()
Class search(webapp2.RequestHandler):
  def post(self):
    x = userData.query().filter("age >=",1)  #error points to this line

我收到错误:无法过滤非Node参数;收到'年龄> ='

我遵循https://developers.google.com/appengine/docs/python/datastore/queries

中提到的语法

请告诉我如何解决此问题。

1 个答案:

答案 0 :(得分:12)

我终于在Google App Engine (python): filter users based on custom fields找到了答案。
有关此文档的文档在https://developers.google.com/appengine/docs/python/ndb/queries#properties_by_string

中提及

Model类中定义的属性必须引用为ndb.GenericProperty()。 对于问题中提到的代码,过滤器语法应为:

x = userData.query().filter(ndb.GenericProperty("age") >= 1).get()