diff --git a/django/db/models/query.py b/django/db/models/query.py index 9cc7659c69..ab85bdc348 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -386,7 +386,7 @@ class QuerySet(object): """ assert self.query.can_filter(), \ "Cannot use 'limit' or 'offset' with in_bulk" - assert isinstance(id_list, (tuple, list)), \ + assert isinstance(id_list, (tuple, list, set, frozenset)), \ "in_bulk() must be provided with a list of IDs." if not id_list: return {} diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py index 94c16ff071..e1973e8456 100644 --- a/tests/modeltests/lookup/models.py +++ b/tests/modeltests/lookup/models.py @@ -102,6 +102,12 @@ Article 4 >>> Article.objects.in_bulk([3]) {3: } +>>> Article.objects.in_bulk(set([3])) +{3: } +>>> Article.objects.in_bulk(frozenset([3])) +{3: } +>>> Article.objects.in_bulk((3,)) +{3: } >>> Article.objects.in_bulk([1000]) {} >>> Article.objects.in_bulk([])