summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorPerry Roper <git@accounts.perry.io>2016-12-15 01:54:29 +0700
committerTim Graham <timograham@gmail.com>2016-12-14 13:54:29 -0500
commit3be2268992767d203159818c5353f959360808a7 (patch)
treeda1648df6f303523bb3c4b712dd45286a4be6134 /docs
parentadb791fdcbdbd6d1b5c258d114b88953d2248c13 (diff)
Added Prefetch import to first use in QuerySet docs.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/querysets.txt2
1 files changed, 2 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 0d89f221b9..9f2af1359f 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -1084,6 +1084,7 @@ the prefetch operation.
In its simplest form ``Prefetch`` is equivalent to the traditional string based
lookups:
+ >>> from django.db.models import Prefetch
>>> Restaurant.objects.prefetch_related(Prefetch('pizzas__toppings'))
You can provide a custom queryset with the optional ``queryset`` argument.
@@ -3138,6 +3139,7 @@ The ``lookup`` argument describes the relations to follow and works the same
as the string based lookups passed to
:meth:`~django.db.models.query.QuerySet.prefetch_related()`. For example:
+ >>> from django.db.models import Prefetch
>>> Question.objects.prefetch_related(Prefetch('choice_set')).get().choice_set.all()
<QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]>
# This will only execute two queries regardless of the number of Question