Reputation: 12753
There is an entity in the Questions table with ID 6544293208522752. When I try to get this back using Questions.get_by_id(6544293208522752) it returns None.
------ Update
To get the parent, categoryKey is just being passed in as an integer:
def questionsKey(categoryKey):
return ndb.Key('Questions', categoryKey)
QuestionID is obtained via a get request, one page sends question.key.id()
, the other gets it with questionID = int(self.request.get('ID'))
Upvotes: 0
Views: 89
Reputation: 7158
because you are storing the entity with a parent you need to provide that to the get_by_id
function too.
entity = Questions.get_by_id(6544293208522752, parent=questionsKey(questionCategory))
otherwise you wont get the entity back.
Upvotes: 1
Reputation: 10360
Are you mixing up string and int IDs? Datastore models can have either, but they're not the same. (The auto-generated IDs are ints but, for example, an ID passed as a URL parameter will be a string and you'll need to convert it.)
Upvotes: 1