0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

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
This commit is contained in:
Malcolm Tredinnick 2008-07-11 10:03:04 +00:00
parent 7936c0b917
commit 88c17b5821

View File

@ -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
======================