HTTPS clone URL
Subversion checkout URL
Please sign in to comment.
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.
- Loading branch information...
Showing with 616 additions and 65 deletions.
- +13 −5 django/contrib/contenttypes/generic.py
- +1 −1 django/db/models/__init__.py
- +30 −21 django/db/models/fields/related.py
- +106 −35 django/db/models/query.py
- +29 −0 docs/ref/models/queries.txt
- +86 −1 docs/ref/models/querysets.txt
- +15 −0 docs/releases/1.7.txt
- +10 −0 tests/prefetch_related/models.py
- +326 −2 tests/prefetch_related/tests.py