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::
|
788 | 788 | The ``update()`` method is applied instantly and returns the number of rows |
789 | 789 | affected by the query. The only restriction on the ``QuerySet`` that is |
790 | 790 | updated 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. |
| 791 | table. You can filter based on related fields, but you can only update columns |
| 792 | in the model's main table. Example:: |
| 793 | |
| 794 | >>> b = Blog.objects.get(pk=1) |
| 795 | |
| 796 | # Update all the headlines belonging to this Blog. |
| 797 | >>> Entry.objects.select_related().filter(blog=b).update(headline='Everything is the same') |
793 | 798 | |
794 | 799 | Be aware that the ``update()`` method is converted directly to an SQL |
795 | 800 | statement. It is a bulk operation for direct updates. It doesn't run any |