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
中提到的语法请告诉我如何解决此问题。
答案 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()