summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorArtur Frysiak <artur@frysiak.net>2014-02-15 22:44:14 +0100
committerTim Graham <timograham@gmail.com>2014-02-17 14:46:13 -0500
commitfaf6a911ad7357c8dd1defa3be0317a8418febf7 (patch)
tree75ebbb6b93ea6d574185472bc1d7bf82df053a7e /docs/ref
parenta7639722f57eebc71cd396512e1fe5c86bebbf15 (diff)
Fixed #22023 -- Raised an error for values() followed by defer() or only().
Previously, doing so resulted in invalid data or crash. Thanks jtiai for the report and Karol Jochelson, Jakub Nowak, Loic Bistuer, and Baptiste Mispelon for reviews.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/querysets.txt15
1 files changed, 12 insertions, 3 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 05f7d36aa6..339b5e18fe 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -502,14 +502,23 @@ A few subtleties that are worth mentioning:
made after a ``values()`` call will have its extra selected fields
ignored.
+* Calling :meth:`only()` and :meth:`defer()` after ``values()`` doesn't make
+ sense, so doing so will raise a ``NotImplementedError``.
+
+.. versionadded:: 1.7
+
+ The last point above is new. Previously, calling :meth:`only()` and
+ :meth:`defer()` after ``values()`` was allowed, but it either crashed or
+ returned incorrect results.
+
A ``ValuesQuerySet`` is useful when you know you're only going to need values
from a small number of the available fields and you won't need the
functionality of a model instance object. It's more efficient to select only
the fields you need to use.
-Finally, note a ``ValuesQuerySet`` is a subclass of ``QuerySet``, so it has all
-methods of ``QuerySet``. You can call ``filter()`` on it, or ``order_by()``, or
-whatever. Yes, that means these two calls are identical::
+Finally, note that a ``ValuesQuerySet`` is a subclass of ``QuerySet`` and it
+implements most of the same methods. You can call ``filter()`` on it,
+``order_by()``, etc. That means that these two calls are identical::
Blog.objects.values().order_by('id')
Blog.objects.order_by('id').values()