When creating a new entity of class Example(ndb.Model) I can set the parent as follows:
e1 = Example(parent=some_entity.key)
e1.put()
This gets saved in the Datastore and everything works.
I can just as well set the id:
e2 = Example(id='some_unique_id')
e2.put()
But when I try to set both the id and the parent of an entity it seems the parent is not getting set:
e3 = Example(parent=some_entity.key, id="some_other_unique_id")
e3.put()
Also, the above seems to allow me to save the e3 without an issue, however I am no longer able to get it via it's id. The following doesn't work:
Example.get_by_id("some_other_unique_id")
returns None.
Is there any way I could both set the parent and an id on an entity? I tried building a key with the ancestor path using ndb.Key() but to no avail.