I wonder if anybody has encountered the strange problem on Google App Engine\'s NDB: after creating a new entity and saving it by put()
; and then query()<
As @JesseRusak said, you need a Dummy ancestor to solve this little problem (I had the same problem that you recently).
But I didn't make a new DummyEntity, just only a DummyKey for a DummyAncestor. Try this for your problem:
class Item(ndb.Model):
...
...
items = Item.query(ancestor=ndb.Key(Item, 'Items')).fetch()
length1 = len(items)
item = Item(parent=ndb.Key(Item, 'Items'))
item.put()
items = Item.query(ancestor=ndb.Key(Item, 'Items')).fetch()
length2 = len(items)
At least in my case, the DummyAncestor worked.