在django app中,我尝试设置:
connect('db', host='user:pass@ec2-23-20-248-142.compute-1.amazonaws.com:47468')
但总是回归:
MongoClient('localhost',27017)
答案 0 :(得分:-1)
您是否尝试过类似下面的“URI样式连接”?
_MONGODB_USER = MONGO_USER
_MONGODB_PASSWD = MONGO_PASSWD
_MONGODB_HOST = 'ec2-23-20-248-142.compute-1.amazonaws.com:47468'
_MONGODB_NAME = 'db'
_MONGODB_DATABASE_HOST = 'mongodb://%s:%s@%s/%s' % (_MONGODB_USER, _MONGODB_PASSWD, _MONGODB_HOST, _MONGODB_NAME)
mongoengine.connect(_MONGODB_NAME, host=_MONGODB_DATABASE_HOST)