Skip to content

Commit

Permalink
Added another bit to the update() queryset docs about avoiding race c…
Browse files Browse the repository at this point in the history
…onditions

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16517 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jul 5, 2011
1 parent 8b34a01 commit 471a841
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/ref/models/querysets.txt
Expand Up @@ -1328,6 +1328,10 @@ memory. The former is more efficient. For example, instead of doing this::


Entry.objects.get(id=10).update(comments_on=False) Entry.objects.get(id=10).update(comments_on=False)


Using ``update()`` instead of loading the object into memory also prevents a
race condition where something might change in your database in the short
period of time between loading the object and calling ``save()``.

Finally, note that the ``update()`` method does an update at the SQL level and, Finally, note that the ``update()`` method does an update at the SQL level and,
thus, does not call any ``save()`` methods on your models, nor does it emit the thus, does not call any ``save()`` methods on your models, nor does it emit the
``pre_save`` or ``post_save`` signals (which are a consequence of calling ``pre_save`` or ``post_save`` signals (which are a consequence of calling
Expand Down

0 comments on commit 471a841

Please sign in to comment.