Skip to content

Commit a9d5493

Browse files
Added prefetch_related to documentation (#644)
1 parent 5d91356 commit a9d5493

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/querying_history.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,9 @@ To filter changes to the data, a relationship to the history can be established.
162162
163163
164164
Poll.objects.filter(history__history_user=4)
165+
166+
You can also prefetch the objects with this relationship using somthing like this for example to prefetch order by history_date descending:
167+
168+
.. code-block:: python
169+
Poll.objects.filter(something).prefetch_related(Prefetch('history', queryset=Poll.history.order_by('-history_date'),
170+
to_attr='ordered_histories')

0 commit comments

Comments
 (0)