mongodb - Django + mongoengine, connect to mongo when used as auxiliary database -


i'm trying connect mongodb using mongoengine.

mysql default database, , have 'mongoengine.django.mongo_auth' in installed apps. removed 'auth_user_model = 'mongo_auth.mongouser'' due errors not having default connection.

i use mongo celery don't think there's problem setup. how attempting connect - code in views.py

from mongoengine import connect  my_connect = connect('my_db', alias='mongo') test = test(name='a_name', desc='a desc') test.save(using='mongo') my_connect.connection.disconnect() 

have managed sort out:

#settings.py mongoengine import register_connection register_connection(alias='default',name='db_name')  #models.py mongoengine import document, stringfield (etc)  class my_col(document):     field_a = stringfield()   #in app mongoengine import connect my_con = connect('db_name', alias='default') item = my_col(field_a='something') item.save() my_con.disconnect() 

Comments