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
I get an error: Cannot filter a non-Node argument; received 'age >='
I am following the syntax mentioned at https://developers.google.com/appengine/docs/python/datastore/queries
Please let me know how to resolve this issue.
I finally found answer for this at
Google App Engine (python): filter users based on custom fields.
The docs for this are mentioned at https://developers.google.com/appengine/docs/python/ndb/queries#properties_by_string
The property defined in Model class must be refered as ndb.GenericProperty(). For the code mentioned in the question, the filter syntax should be:
x = userData.query().filter(ndb.GenericProperty("age") >= 1).get()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With