Settings

Connection Settings

Additional flags may be passed to pymongo.Connection using the OPTIONS dictionary:

DATABASES = {
    'default' : {
        'ENGINE' : 'django_mongodb_engine',
        'NAME' : 'my_database',
        ...
        'OPTIONS' : {
            'slave_okay' : True,
            'tz_aware' : True,
            'network_timeout' : 42,
            ...
        }
    }
}

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 Connection. For a list of possible options head over to the PyMongo documentation on connection options.

Safe Operations (getLastError)

Use the OPERATIONS dict to specify extra flags passed to Collection.save, update() or remove() (and thus to getLastError):

'OPTIONS' : {
    'OPERATIONS' : {'w' : 3},
    ...
}

Since any options to getLastError imply safe=True, this configuration passes safe=True, w=3 as keyword arguments to each of save(), update() and remove().

Get a more fine-grained setup by introducing another layer to this dict:

'OPTIONS' : {
    'OPERATIONS' : {
        'save' : {'safe' : True},
        'update' : {},
        'delete' : {'fsync' : 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 getLastError flags may be found in the MongoDB documentation.