diff options
| author | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-11-07 00:25:05 +0700 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-11-07 14:49:49 +0200 |
| commit | f51c1f590085556abca44fd2a49618162203b2ec (patch) | |
| tree | 4577d32e1e99bb7f1032ee394a80692e552846e5 /django/db/models/__init__.py | |
| parent | b1b04df06522b092a9b4768d2d61c52956e00eca (diff) | |
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.
Diffstat (limited to 'django/db/models/__init__.py')
| -rw-r--r-- | django/db/models/__init__.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index 13785ed17a..e2f7348ef0 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -4,7 +4,7 @@ from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured # N from django.db.models.loading import ( # NOQA get_apps, get_app_path, get_app_paths, get_app, get_models, get_model, register_models, UnavailableApp) -from django.db.models.query import Q, QuerySet # NOQA +from django.db.models.query import Q, QuerySet, Prefetch # NOQA from django.db.models.expressions import F # NOQA from django.db.models.manager import Manager # NOQA from django.db.models.base import Model # NOQA |
