⚠ 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!

Atomic Updates

Django’s support for updates (using the update() method) can be used to run atomic updates against a single or multiple documents:

Post.objects.filter(...).update(title='Everything is the same')

results in a update() query that uses the atomic $set operator to update the title field:

.update(..., {'$set': {'title': 'Everything is the same'}})

It’s also possible to use F() objects which are translated into $inc operations. For example,

Post.objects.filter(...).update(visits=F('visits')+1)

is translated to:

.update(..., {'$inc': {'visits': 1}})