Reputation: 18982
The docs says that ancestor
will apply a filter of given ancestor being somewhere in the ancestry tree.
You can filter your datastore queries to a specified ancestor, so that results contain only entities containing that ancestor. In other words, all of the results will have the ancestor as their parent, or parent's parent, or etc. Passing None as a parameter does not query for entities without ancestors and will return errors.
Can I somehow filter on one level, immediate ancestor relationship so that a query will provide models having specific parent? Or must I store parent relationship in a ReferenceProperty
and filter on that?
Upvotes: 3
Views: 331
Reputation: 13629
You are right: querying for ancestor will get all parents, not only the direct one. To get the direct parent only, you must store it in a property (can be a ReferenceProperty or you can just store an encoded key in a StringProperty), then query for it.
Upvotes: 4