diff --git a/django/db/models/query.py b/django/db/models/query.py index 4b6645569f..dbd37b1822 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -388,6 +388,7 @@ class QuerySet(object): self.model._base_manager._insert(objs_with_pk, fields=fields, using=self.db) if objs_without_pk: self.model._base_manager._insert(objs_without_pk, fields=[f for f in fields if not isinstance(f, AutoField)], using=self.db) + return objs def get_or_create(self, **kwargs): """ diff --git a/tests/regressiontests/bulk_create/tests.py b/tests/regressiontests/bulk_create/tests.py index 8d3faa2379..d7d19a54aa 100644 --- a/tests/regressiontests/bulk_create/tests.py +++ b/tests/regressiontests/bulk_create/tests.py @@ -17,7 +17,8 @@ class BulkCreateTests(TestCase): ] def test_simple(self): - Country.objects.bulk_create(self.data) + created = Country.objects.bulk_create(self.data) + self.assertEqual(len(created), 4) self.assertQuerysetEqual(Country.objects.order_by("-name"), [ "United States of America", "The Netherlands", "Germany", "Czech Republic" ], attrgetter("name"))