ENVIRONMENT_CONFIG_FILE
包含:
MONGODB_SETTINGS = {
'host': 'localhost',
'port': 27017,
'db': 'my_db'
}
//in my application
app.config.from_envvar('ENVIRONMENT_CONFIG_FILE_LOCATION')
MongoEngine(app)
我想要设置read_prefrences
,我可以在应用程序级别
from pymongo import ReadPreference
app.config['MONGODB_SETTINGS']['read_prefrences'] = ReadPreference.PRIMARY
MongoEngine(app)
哪个会起作用,但我想在配置文件中设置read_preferences。我是如何做到这一点的,因为ReadPreference.PRIMARY
不是string
?