Settings¶
Client Settings¶
Additional flags may be passed to pymongo.MongoClient
using the
OPTIONS
dictionary:
DATABASES = {
'default' : {
'ENGINE' : 'django_mongodb_engine',
'NAME' : 'my_database',
...
'OPTIONS' : {
'socketTimeoutMS' : 500,
...
}
}
}
All of these settings directly mirror PyMongo settings. In fact, all Django
MongoDB Engine does is lower-casing the names before passing the flags to
MongoClient
. For a list of possible options head over to the
PyMongo documentation on client options.
Acknowledged Operations¶
Use the OPERATIONS
dict to specify extra flags passed to
Collection.save
,
update()
or
remove()
(and thus included in the write concern):
'OPTIONS' : {
'OPERATIONS' : {'w' : 3},
...
}
Get a more fine-grained setup by introducing another layer to this dict:
'OPTIONS' : {
'OPERATIONS' : {
'save' : {'w' : 3},
'update' : {},
'delete' : {'j' : True}
},
...
}
Note
This operations map to the Django operations save, update and delete (not to MongoDB operations). This is because Django abstracts “insert vs. update” into save.
A full list of write concern flags may be found in the MongoDB documentation.