⚠ Documentation version

These are the Git version docs. Docs for 0.4 (PyPI) are here.

Help out!

To make this documentation even better, we'd love to receive your feedback and suggestions for improvement!

Warning

These APIs are available for MongoDB only, so using any of these features breaks portability to other non-relational databases (Google App Engine, Cassandra, Redis, ...). For the sake of portability you should try to avoid database-specific features whenever possible.

Lower-Level API

from django_mongodb_engine.contrib import MongoDBManager

class FooModel(models.Model):
    ...
    objects = MongoDBManager()
>>> FooModel.objects.raw_query(...)
>>> FooModel.objects.raw_update(...)
MongoDBManager.raw_query(query=None)

Does a raw MongoDB query. The optional parameter query is the spec passed to PyMongo’s <Collection.find> pymongo.Collection.find().

MongoDBManager.raw_update(spec_or_q, update_dict, **kwargs)

Does a raw MongoDB update. spec_or_q is either a MongoDB filter dict or a Q instance that selects the records to update. update_dict is a MongoDB style update document containing either a new document or atomic modifiers such as $inc.

Keyword arguments will be passed to pymongo.Collection.update().

MongoDBManager.distinct(*args, **kwargs)

Runs a distinct() query against the database.