Ticket #14004: 14004.2.diff

File 14004.2.diff, 1.3 KB (added by Tim Graham, 14 years ago)

tweaks to existing patch

  • docs/ref/models/querysets.txt

    diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
    index 87680d3..7c288e8 100644
    a b that it will be at some point, then using ``some_query_set.exists()`` will do  
    12211221more overall work (an additional query) than simply using
    12221222``bool(some_query_set)``.
    12231223
     1224``update()``
     1225~~~~~~~~~~~~
     1226
     1227.. method:: update()
     1228
     1229Returns the number of rows affected by a SQL update query. The ``update()``
     1230method is applied instantly and the only restriction on the :class:`QuerySet`
     1231that is updated is that it can only access one database table, the model's main
     1232table. You can filter based on related fields, but you can only update columns
     1233in the model's main table.
     1234
     1235For example, if you wanted to update all blog entries to use the same headline::
     1236
     1237    >>> b = Blog.objects.get(pk=1)
     1238
     1239    # Update all the headlines belonging to this Blog.
     1240    >>> Entry.objects.select_related().filter(blog=b).update(headline='Everything is the same')
     1241
     1242The ``update()`` method does bulk updates and does not call any ``save()``
     1243methods on your models, or emit the ``pre_save`` or ``post_save`` signals
     1244(which are a consequence of calling ``save()``).
     1245
    12241246.. _field-lookups:
    12251247
    12261248Field lookups
Back to Top