From 88c17b582194d34e0a96864b7e3153f6de2dd0e1 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 11 Jul 2008 10:03:04 +0000 Subject: [PATCH] Documented that the update() method on querysets is a direct SQL call, not the same as looping over the queryset and calling save() on each item (which is less efficient). Fixed #7447. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7884 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/db-api.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/db-api.txt b/docs/db-api.txt index 9a604bf320..5fdcd946bd 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -2212,6 +2212,18 @@ updated is that it can only access one database table, the model's main table. So don't try to filter based on related fields or anything like that; it won't work. +Be aware that the ``update()`` method is converted directly to an SQL +statement. It is a bulk operation for direct updates. It doesn't run any +``save()`` methods on your models, or emit the ``pre_save`` or ``post_save`` +signals (which are a consequence of calling ``save()``). If you want to save +every item in a ``QuerySet`` and make sure that the ``save()`` method is +called on each instance, you don't need any special function to handle that. +Just loop over them and call ``save()``: + + for item in my_queryset: + item.save() + + Extra instance methods ======================