Skip to content

Tag: mongodb

Setting up MongoDB + Django

I am new to Mongo DB and Django. I’ve been trying to use Mongo DB as my primary Database for Django. I’ve installed MongoDB and Django-nonrel as per the following link: Django – MongoDB setup The version of django-nonrel, i am using is 1.7. Clone link to it: pip install git+https://github.co…

TypeError: ObjectId(”) is not JSON serializable

My response back from MongoDB after querying an aggregated function on document using Python, It returns valid response and i can print it but can not return it. Error: Print: But When i try to return: It is RESTfull call: db is well connected and collection is there too and I got back valid expected result b…

Removing _id element from Pymongo results

I’m attempting to create a web service using MongoDB and Flask (using the pymongo driver). A query to the database returns documents with the “_id” field included, of course. I don’t want to send this to the client, so how do I remove it? Here’s a Flask route: This returns: I tho…

Map Reduce on timestamps

Mongodb Database: How can I Map-Reduce or aggregate on the above data to generate an output as: I am trying to write some code but its difficult to average on unsorted dates. Are there any built in functions averaging on time to do this? Answer You could do min/max on the dates like described here for numbers…