Django

Code

Changeset 7884

Show
Ignore:
Timestamp:
07/11/08 05:03:04 (2 months ago)
Author:
mtredinnick
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/db-api.txt

    r7791 r7884  
    22132213it won't work. 
    22142214 
     2215Be aware that the ``update()`` method is converted directly to an SQL 
     2216statement. It is a bulk operation for direct updates. It doesn't run any 
     2217``save()`` methods on your models, or emit the ``pre_save`` or ``post_save`` 
     2218signals (which are a consequence of calling ``save()``). If you want to save 
     2219every item in a ``QuerySet`` and make sure that the ``save()`` method is 
     2220called on each instance, you don't need any special function to handle that. 
     2221Just loop over them and call ``save()``: 
     2222 
     2223    for item in my_queryset: 
     2224        item.save() 
     2225 
     2226 
    22152227Extra instance methods 
    22162228======================