From c2aa836c4f0fda8db0f3bfbea93f1380843913e2 Mon Sep 17 00:00:00 2001 From: Perry Roper Date: Thu, 15 Dec 2016 01:54:29 +0700 Subject: [PATCH] [1.10.x] Added Prefetch import to first use in QuerySet docs. Backport of 3be2268992767d203159818c5353f959360808a7 from master --- docs/ref/models/querysets.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index b6f35bb12d..7e2dc7abca 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1044,6 +1044,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. @@ -3098,6 +3099,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() , , ]> # This will only execute two queries regardless of the number of Question