summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-06-26 18:08:42 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-06-26 18:08:42 +0300
commitb6c356b7bb97f3d6d4831b31e67868313bbbc090 (patch)
tree1cd4c587080703c5b86b13349858509ce145ca4c /docs
parent531878302735e6a2b36d82b584947bbf8eae8111 (diff)
Fixed #17485 -- Made defer work with select_related
This commit tackles a couple of issues. First, in certain cases there were some mixups if field.attname or field.name should be deferred. Field.attname is now always used. Another issue tackled is a case where field is both deferred by .only(), and selected by select_related. This case is now an error. A lot of thanks to koniiiik (Michal Petrucha) for the patch, and to Andrei Antoukh for review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/querysets.txt11
1 files changed, 8 insertions, 3 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index eef22728ab..2876f1474d 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -1081,11 +1081,13 @@ to ``defer()``::
# Load all fields immediately.
my_queryset.defer(None)
+.. versionchanged:: 1.5
+
Some fields in a model won't be deferred, even if you ask for them. You can
never defer the loading of the primary key. If you are using
:meth:`select_related()` to retrieve related models, you shouldn't defer the
-loading of the field that connects from the primary model to the related one
-(at the moment, that doesn't raise an error, but it will eventually).
+loading of the field that connects from the primary model to the related
+one, doing so will result in an error.
.. note::
@@ -1145,9 +1147,12 @@ logically::
# existing set of fields).
Entry.objects.defer("body").only("headline", "body")
+.. versionchanged:: 1.5
+
All of the cautions in the note for the :meth:`defer` documentation apply to
``only()`` as well. Use it cautiously and only after exhausting your other
-options.
+options. Also note that using :meth:`only` and omitting a field requested
+using :meth:`select_related` is an error as well.
using
~~~~~