[Solved]-Mongoengine… query something not in a ListField?

23👍

To find any pages that don’t have the tags coding use the $nin operator:

Page.objects(tags__nin=['coding'])
👤Ross

1👍

I would skip using the build-in mongo syntax on this one and just use a raw query:

Page.objects(__raw__={"tags" : {"$ne" : ['coding']}})

As query get more complicated, your going to wish you set it up like this.

Leave a comment