summaryrefslogtreecommitdiff
path: root/django/db/models
diff options
context:
space:
mode:
authorBryan Marty <bryanmarty@gmail.com>2015-10-29 23:24:46 -0700
committerTim Graham <timograham@gmail.com>2015-12-26 17:57:19 -0500
commit62ca2dea04489bdb23df1c7815439287c6d44630 (patch)
treeeb12cc7fef04d1bce3e1a3f6b1c14124884f6da0 /django/db/models
parent2a7ce34600d0f879e93c9a5e02215948ed3bb6ac (diff)
Fixed #8065 -- Made id_list an optional argument for QuerySet.in_bulk().
Diffstat (limited to 'django/db/models')
-rw-r--r--django/db/models/query.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index e8d9006b48..45c0320254 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -559,16 +559,19 @@ class QuerySet(object):
return objects[0]
return None
- def in_bulk(self, id_list):
+ def in_bulk(self, id_list=None):
"""
Returns a dictionary mapping each of the given IDs to the object with
- that ID.
+ that ID. If `id_list` isn't provided, the entire QuerySet is evaluated.
"""
assert self.query.can_filter(), \
"Cannot use 'limit' or 'offset' with in_bulk"
- if not id_list:
- return {}
- qs = self.filter(pk__in=id_list).order_by()
+ if id_list is not None:
+ if not id_list:
+ return {}
+ qs = self.filter(pk__in=id_list).order_by()
+ else:
+ qs = self._clone()
return {obj._get_pk_val(): obj for obj in qs}
def delete(self):