Skip to content

Commit

Permalink
Corrected QuerySet.prefetch_related() note about GenericRelation().
Browse files Browse the repository at this point in the history
GenericRelation is a reverse generic relationship so it's always
homogeneous. Mentioning this as a restriction is confusing.
  • Loading branch information
felixxm authored Sep 16, 2023
1 parent 814e7bc commit 88b5b7b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/ref/models/querysets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1149,10 +1149,11 @@ one-to-one.

``prefetch_related``, on the other hand, does a separate lookup for each
relationship, and does the 'joining' in Python. This allows it to prefetch
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
many-to-many, many-to-one, and
:class:`~django.contrib.contenttypes.fields.GenericRelation` 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.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
Expand Down

0 comments on commit 88b5b7b

Please sign in to comment.