aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_relations_hyperlink.py
diff options
context:
space:
mode:
authorTom Christie2014-12-10 21:09:45 +0000
committerTom Christie2014-12-10 21:09:45 +0000
commitca7b1f6d5189398be8a0d24b1e01577281b1b187 (patch)
tree43892cdb5c9079ee5e2a464cd3e4eae98e755c11 /tests/test_relations_hyperlink.py
parent720a37d3dedc501968bebaca3a339c72392b9c81 (diff)
downloaddjango-rest-framework-ca7b1f6d5189398be8a0d24b1e01577281b1b187.tar.bz2
Optimizations play nicely with select_related, prefetch_related
Diffstat (limited to 'tests/test_relations_hyperlink.py')
-rw-r--r--tests/test_relations_hyperlink.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test_relations_hyperlink.py b/tests/test_relations_hyperlink.py
index e741e99b..f1b882ed 100644
--- a/tests/test_relations_hyperlink.py
+++ b/tests/test_relations_hyperlink.py
@@ -92,6 +92,12 @@ class HyperlinkedManyToManyTests(TestCase):
with self.assertNumQueries(4):
self.assertEqual(serializer.data, expected)
+ def test_many_to_many_retrieve_prefetch_related(self):
+ queryset = ManyToManySource.objects.all().prefetch_related('targets')
+ serializer = ManyToManySourceSerializer(queryset, many=True, context={'request': request})
+ with self.assertNumQueries(2):
+ serializer.data
+
def test_reverse_many_to_many_retrieve(self):
queryset = ManyToManyTarget.objects.all()
serializer = ManyToManyTargetSerializer(queryset, many=True, context={'request': request})