Forums

mongodb connection with mongoengine django-mongonaut mongolab

Hi All

Looking for some help to establish a connection with a mongodb host on mongolab. I'm also hoping to use django-mongonaut with mongoengine.

I'm a little new to this but see it's a common question so would like document it here so it's easy for others to follow.

Thanks Andy

Have a look at this forum thread

Hi Glenn

My first step is what I edit in my settings.py to get the connection to work? I have what was posted in the forum in my settings.py but am coming up short. The vital link in that post to mongolab isn't connecting and as a newbie pull this in to one doc would be helpful.


To do this you need a paid for PythonAnywhere account

To connect from PythonAnywhere to MongoLab then your connection settings will look something like mongodb://my-db-user:my-db-password@ds033217.mongolab.com:33217/my-database -- see this page on MongoLab's support pages.

In settings.py

from pymongo import MongoClient

MongoClient('mongodb://user_name:password@unique_url.mongolab.com:port/db_name')

Is working for me, so far

Here's a help page about MongoDB on PythonAnywhere that hopefully will be useful for anyone with questions about this in the future. Any suggestions for extra stuff we should put on there much appreciated!