From 62ca2dea04489bdb23df1c7815439287c6d44630 Mon Sep 17 00:00:00 2001 From: Bryan Marty Date: Thu, 29 Oct 2015 23:24:46 -0700 Subject: Fixed #8065 -- Made id_list an optional argument for QuerySet.in_bulk(). --- django/db/models/query.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'django') 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): -- cgit v1.3