This is an old question, so I'm not sure if the ID is not a key. But to answer this:
query = Story.all() query.filter('ID **NOT IN** =', [100,200,..,..])
... With ndb, you can definitely request items that are in the list. For example, see Docs here for IN and != . Here's how to filter as requested by OP:
query = Story.filter(Story.id.IN([100,200,..,..])
We can even request items that are in the list of duplicate keys:
def all(user_id):
Some reservations:
It says that mentioning that to execute these types of queries, Datastore performs several queries behind the scenes, which (1) may take some time to execute, (2) take longer if you search in duplicate properties, and (3 ) will increase your expenses due to additional operations.
source share