[django/django] f51c1f: Fixed #17001 -- Custom querysets for prefetch_rela...

1 view
Skip to first unread message

GitHub

unread,
Nov 7, 2013, 7:57:15 AM11/7/13
to django-...@googlegroups.com
Branch: refs/heads/master
Home: https://github.com/django/django
Commit: f51c1f590085556abca44fd2a49618162203b2ec
https://github.com/django/django/commit/f51c1f590085556abca44fd2a49618162203b2ec
Author: Loic Bistuer <loic.b...@sixmedia.com>
Date: 2013-11-07 (Thu, 07 Nov 2013)

Changed paths:
M django/contrib/contenttypes/generic.py
M django/db/models/__init__.py
M django/db/models/fields/related.py
M django/db/models/query.py
M docs/ref/models/queries.txt
M docs/ref/models/querysets.txt
M docs/releases/1.7.txt
M tests/prefetch_related/models.py
M tests/prefetch_related/tests.py

Log Message:
-----------
Fixed #17001 -- Custom querysets for prefetch_related.

This patch introduces the Prefetch object which allows customizing prefetch
operations.

This enables things like filtering prefetched relations, calling select_related
from a prefetched relation, or prefetching the same relation multiple times
with different querysets.

When a Prefetch instance specifies a to_attr argument, the result is stored
in a list rather than a QuerySet. This has the fortunate consequence of being
significantly faster. The preformance improvement is due to the fact that we
save the costly creation of a QuerySet instance.

Thanks @akaariai for the original patch and @bmispelon and @timgraham
for the reviews.



Reply all
Reply to author
Forward
0 new messages