MongoEngine / django-mongoengine

django mongoengine integration
Other
750 stars 206 forks source link

Multiple DB connection error. #49

Closed austinjung closed 8 years ago

austinjung commented 8 years ago

Commit <8ad246f2178b0e9c08a0f5346e3f6278f5c2dbbc> : simple module loading

Is it possible the above commit can break multiple DB connection below? It works with the previous versions, but from the above commit version, it throw errors about Connection with alias "advising" has not been defined.

MONGODB_DATABASES = { 'default': { 'name': 'django_mongoengine',

'host': '127.0.0.1',

    # "password": database_password,
    # "username": database_user,
    'tz_aware': True, # if you using timezones in django (USE_TZ = True)
},
'advising': {
    'name': 'ctAdvising',
    'host': 'localhost',
    'tz_aware': True, # if you using timezones in django (USE_TZ = True)
},

}


ConnectionError at /email_sent_logs/ Connection with alias "advising" has not been defined Request Method: GET Request URL: http://127.0.0.1:7000/email_sent_logs/ Django Version: 1.8.5 Exception Type: ConnectionError Exception Value:
Connection with alias "advising" has not been defined

Exception Location: /usr/local/lib/python2.7/dist-packages/mongoengine/connection.py in get_connection, line 101

/srv/kaizen_api/views.py in EmailSentLogViewSet queryset = EmailSentLog.objects.all() ... /usr/local/lib/python2.7/dist-packages/mongoengine/queryset/manager.py in get queryset = queryset_class(owner, owner._get_collection()) ... /usr/local/lib/python2.7/dist-packages/mongoengine/document.py in _get_collection db = cls._get_db() ... /usr/local/lib/python2.7/dist-packages/mongoengine/document.py in _get_db return get_db(cls._meta.get("db_alias", DEFAULT_CONNECTION_NAME)) ... /usr/local/lib/python2.7/dist-packages/mongoengine/connection.py in get_db conn = get_connection(alias) ... ▼ Local vars Variable Value alias 'advising' reconnect False /usr/local/lib/python2.7/dist-packages/mongoengine/connection.py in get_connection raise ConnectionError(msg) ... ▼ Local vars Variable Value msg 'Connection with alias "advising" has not been defined' alias 'advising' reconnect False

last-partizan commented 8 years ago

Now you need to include django_mongoengine into your INSTALLED_APPS.

austinjung commented 8 years ago

Thanks. It works.