diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py index 729f011446..9b43d52c8a 100644 --- a/tests/many_to_many/tests.py +++ b/tests/many_to_many/tests.py @@ -512,6 +512,12 @@ class ManyToManyTests(TestCase): a4.publications.add(self.p1) self.assertEqual(a4.publications.count(), 2) + def test_create_after_prefetch(self): + a4 = Article.objects.prefetch_related("publications").get(id=self.a4.id) + self.assertSequenceEqual(a4.publications.all(), [self.p2]) + p5 = a4.publications.create(title="Django beats") + self.assertCountEqual(a4.publications.all(), [self.p2, p5]) + def test_set_after_prefetch(self): a4 = Article.objects.prefetch_related("publications").get(id=self.a4.id) self.assertEqual(a4.publications.count(), 1)