9
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

次のエラーが表示されます:ノード以外の引数をフィルター処理できません。「年齢>=」を受け取りました

https://developers.google.com/appengine/docs/python/datastore/queriesに記載されている構文に従っています

この問題を解決する方法を教えてください。

4

1 に答える 1

15


私はついに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()
于 2013-11-01T23:51:29.360 に答える