In your MONGODB_SETTINGS dictionary, the key for the database name should be "db", not "DB" (i.e. all lowercase letters).
The error you get is that the MongoEngine extension cannot find the "db" entry in your configuration and therefore uses "default" as the database name.
Edit
Upon further inspection, it seems like this is an error somewhere in (Flask-) MongoEngine (or possibly pymongo), where the default read_preference in mongoengine.connect is False instead of the actual read preference and does not translate into the actual default value in pymongo
If you add
from pymongo import read_preferences
for your import and
'read_preference': read_preferences.ReadPreference.PRIMARY
into your configuration dictionary, it should work (which is the default read_preference in pymongo)
Samuel littley
source share