Reputation: 67039
I am trying to use the filter() method based on a key argument. For example:
user_id="agxkZXZ-emFiZXRhLTJyCgsSBFVzZXIYGAw"
d=datamodel.Task.all()
d.filter("user=",user_id)
results=d.fetch(1024)
This produces zero results, and its probably because the key isn't in the right format. If this where gql would I have to use the Key() function like this:
db.gqlQuery("select * from Task where user=Key(:1)",user_id)
However I don't think I can use the Key() function within a filter, but there must be some python functional equivalent... Is there a way to properly format a key to be used within the filter() method?
Upvotes: 0
Views: 139
Reputation: 1472
You can indeed use Key
instances within a filter!
from google.appengine.api.datastore_types import Key
user_id="agxkZXZ-emFiZXRhLTJyCgsSBFVzZXIYGAw"
datamodel.Task.all().filter('user', Key(user_id))
Upvotes: 4