bgenchel
bgenchel

Reputation: 4049

Can't Query by Key in NDB

I'm attempting to query an entity by key assuming ordering by key with ndb.

the line is

query = User.query().filter(User.key > ndb.Key('User', key_id))

and it's throwing a server error:

  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore_types.py", line 1443, in ValidatePropertyKey
'Incomplete key found for reference property %s.' % name)
BadValueError: Incomplete key found for reference property __key__.

Is it just that I'm not allowed to query by key in this way? Other stack overflow posts seem to indicate that what i'm doing should be ok. I can't find anything online pertaining to the error text, and i'm not sure what else would be causing this error.

Any help or insight is greatly appreciated.

Upvotes: 0

Views: 312

Answers (1)

marcadian
marcadian

Reputation: 2618

Try this

query = User.query().filter(User._key > ndb.Key('User', key_id))

Upvotes: 1

Related Questions