python - I can't connect mongodb with django -
i use mongoengine. , below settings:
_mongodb_user = 'user1' _mongodb_passwd = '12345678' _mongodb_host = 'mongodb://user1:damian123@ds99999.mlab.com:23932/projekt_dkjp' _mongodb_name = 'baza1' _mongodb_database_host = \ 'mongodb://%s:%s@%s/%s' \ % (_mongodb_user, _mongodb_passwd, _mongodb_host, _mongodb_name) mongoengine.connect(_mongodb_name, host=_mongodb_host) databases = { 'default': { 'engine': '', }, }
and when run server see problem:
file "c:\users\vbox\pycharmprojects\projekt06\projekt\projekt\settings.py", line 90, in mongoengine.connect(_mongodb_name, host=_mongodb_host) file "c:\users\vbox\appdata\local\programs\python\python35-32\lib\site-packages\mongoengine\connection.py", line 165, in connect return get_connection(alias) file "c:\users\vbox\appdata\local\programs\python\python35-32\lib\site-packages\mongoengine\connection.py", line 128, in get_connection raise connectionerror("cannot connect database %s :\n%s" % (alias, e)) mongoengine.connection.connectionerror: cannot connect database default : false not read preference.
basically, databases should this:
databases = { 'default': { 'engine': 'django.db.backends.sqlite3', 'name': 'mydatabase', } }
source: link
easy understand picture:
a simple doc understand can found here
Comments
Post a Comment