Home > Enterprise >  Pymongo error while trying to call distinct on a collection
Pymongo error while trying to call distinct on a collection

Time:04-05

I'm getting this weird error. I am following the documentation closely and don't understand what I am doing wrong. I pasted an minimal example to replicate the error. Any tip to this fix?

Error message:

TypeError: 'Collection' object is not callable. If you meant to call the 'dictinct' method on a 'Collection' object it is failing because no such method exists.

Code:

import pymongo
client = pymongo.MongoClient('mongodb://localhost:27017')
detached = client['realestate'].detached
print(detached.dictinct('key_facts-build_year'))

CodePudding user response:

You have a typo; the method is distinct() (not dictinct())

  • Related