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()<
I solved this by making the appropriate query, creating the new model record, then appending it to my query before returning it. Modifying yours, it looks like:
class Item(ndb.Model):
...
...
items = Item.query().fetch()
length1 = len(items)
item = Item()
item.put()
appended_items = list()
for existing_item in items:
appended_items.append(existing_item)
appended_items.append(item)
length2 = len(appendeditems)
In this case, appended_items has your query, plus the new element. The list generation is inefficient, but I'm a python/ndb noob and there's probably a way to get the Collection right out of the Query model, which would be much better.