I have the following 2 models in my Google App Engine datastore:
class Search(db.Model):
what = db.StringProperty()
class SearchResult(db.Model):
search = db.ReferenceProperty(Search)
title = db.StringProperty()
content = db.StringProperty()
And, I am trying to retrieve all SearchResult entities for a given Search entity in the following function:
def get_previous_search_results(what='', where=''):
search_results = None
search = db.GqlQuery("SELECT * FROM Search WHERE what = :1", what).fetch(1)
if search:
search_results = db.GqlQuery("SELECT * FROM SearchResult WHERE ANCESTOR IS :1", search[0].key()).fetch(10)
return search_results
However, it always returns an empty set.
Any ideas what I am doing wrong? I've read through the Python Datastore API docs and this seem like the correct way to do this, but it's not working.