0

I'm trying to connect to a Mongo DB with Django and Mongokit (using django-mongokit). When I try to feed it a remote

In settings.py:

DATABASES = {
    'default': dj_database_url.config(default=os.environ['DATABASE_URL']),
    'mongodb': dj_database_url.parse(os.environ['MONGOHQ_URL']),
}

DATABASES is correctly populated with connection data, for what it's worth.

In the main routine:

from mongokit import Connection

# ...
conn = Connection('mongodb')
conn.register([Account])
db = conn.foo
collection = db.bar

This throws a getaddrinfo failed error. Connection(), it seems, wants a PymongoConnection, but I'm not sure how to get that. And when I try feeding a remote URL into DATABASES.mongodb, it freaks out as well. Any ideas?

Edit: Not really a solution, but I ended up just using pymongo straight rather than django-mongokit. Oh well.

greggilbert
  • 1,313
  • 2
  • 13
  • 26

1 Answers1

0

conn = Connection('mongodb') is trying to connect to a served called literally mongodb - using conn = Connection(DATABASES['mongodb']) in whatever way you've got it set up (via app.config?) is going to be the way to do it.

Jon Clements
  • 138,671
  • 33
  • 247
  • 280