pymongo- How can I have distinct values for a field along with other query parameters

You have to make the distinct call on the cursor returned from a find instead of on the collection:

tags = db.mycoll.find({"category": "movie"}).distinct("tags")

pymongo (since v1.1.1) supports collection.distinct('key')


Actually there is a filter parameter you can pass in distinct method as mentioned in the pymongo Doc,

Pymongo Distinct

like this

distinct_tags = db.mycoll.distinct("tags",{"category": "movie"})