Ticket #12859: 12859.2.patch

File 12859.2.patch, 1.3 KB (added by Tim Graham, 8 years ago)

tabs -> spaces for existing patch

  • docs/topics/db/queries.txt

    From 88f462718c0a05ff25dc36b011320523cae38519 Mon Sep 17 00:00:00 2001
    From: Derek Willis <dwillis@gmail.com>
    Date: Sat, 13 Feb 2010 21:50:01 -0500
    Subject: [PATCH] updated docs for multiple object update
     docs/topics/db/queries.txt |    9 +++++++--
     1 files changed, 7 insertions(+), 2 deletions(-)
    diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
    index be16a2b..dc7d0ef 100644
    a b instance you want to point to. Example:: 
    788788The ``update()`` method is applied instantly and returns the number of rows
    789789affected by the query. The only restriction on the ``QuerySet`` that is
    790790updated is that it can only access one database table, the model's main
    791 table. So don't try to filter based on related fields or anything like that;
    792 it won't work.
     791table. You can filter based on related fields, but you can only update columns
     792in the model's main table. Example::
     794    >>> b = Blog.objects.get(pk=1)
     796    # Update all the headlines belonging to this Blog.
     797    >>> Entry.objects.select_related().filter(blog=b).update(headline='Everything is the same')
    794799Be aware that the ``update()`` method is converted directly to an SQL
    795800statement. It is a bulk operation for direct updates. It doesn't run any
Back to Top