[Answered ]-How do I properly query mongoDB through Django?

2👍

The disadvantage of your code is that you pay the cost of setting up a MongoClient and establishing a connection to the server with every request. You should only create a single MongoClient and use it throughout the lifetime of your application. If you test the performance of your example code and compare it to the performance of creating a single MongoClient once, when your application starts, I expect you’ll see that your code is orders of magnitude slower.

Leave a comment