From 69239c0f968ee55cb9ca1e31323fb696db0c2aec Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 29 Oct 2015 18:56:57 -0400 Subject: [PATCH] Fixed #21422 -- Documented that prefetch_related() results must be homogeneous. --- docs/ref/models/querysets.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 0887e94729..61bf4afa2c 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -868,7 +868,10 @@ many-to-many and many-to-one objects, which cannot be done using ``select_related``, in addition to the foreign key and one-to-one relationships that are supported by ``select_related``. It also supports prefetching of :class:`~django.contrib.contenttypes.fields.GenericRelation` and -:class:`~django.contrib.contenttypes.fields.GenericForeignKey`. +:class:`~django.contrib.contenttypes.fields.GenericForeignKey`, however, it +must be restricted to a homogeneous set of results. For example, prefetching +objects referenced by a ``GenericForeignKey`` is only supported if the query +is restricted to one ``ContentType``. For example, suppose you have these models::