summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorAric Coady <aric.coady@gmail.com>2015-04-27 15:23:56 -0700
committerTim Graham <timograham@gmail.com>2015-04-28 11:00:58 -0400
commitb67bd1b483dfda7901a11a6e323db8a7e00c26c4 (patch)
treea052699892f2f9df9c83a92e5907ff0eb1219d6e /django/db/models/sql/query.py
parentc37eb3c870db46f64578e9974f576dd2d8c40f8a (diff)
[1.8.x] Fixed #24719 -- Restored the ability to use interators as queryset related object filters.
Backport of 9c2d8cde77ee6edd407e92f93eacd4624290394f from master
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 7ba94f205b..387b91a60b 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -8,7 +8,7 @@ all about the internals of models in order to get the information it needs.
"""
import copy
import warnings
-from collections import Mapping, OrderedDict
+from collections import Iterator, Mapping, OrderedDict
from itertools import chain, count, product
from string import ascii_uppercase
@@ -1167,6 +1167,9 @@ class Query(object):
field, sources, opts, join_list, path = self.setup_joins(
parts, opts, alias, can_reuse=can_reuse, allow_many=allow_many)
+ # Prevent iterator from being consumed by check_related_objects()
+ if isinstance(value, Iterator):
+ value = list(value)
self.check_related_objects(field, value, opts)
# split_exclude() needs to know which joins were generated for the