diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-05-17 13:29:52 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-05-17 13:34:53 +0200 |
| commit | 009e237cf0c25ce13e73d58feb54ef4f86e47e4e (patch) | |
| tree | d05792ea60b58a06a2f00d7fa214f9c76ac0ec48 /tests/regressiontests/generic_views/list.py | |
| parent | 006c2b8fc166e53d4ffccda9c42ef9fc109e1c8d (diff) | |
Fixed #17535 -- Optimized list generic views.
When allow_empty is False, prevented the view from loading
the entire queryset in memory when pagination is enabled.
Diffstat (limited to 'tests/regressiontests/generic_views/list.py')
| -rw-r--r-- | tests/regressiontests/generic_views/list.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py index 9ad00edc3b..b925758524 100644 --- a/tests/regressiontests/generic_views/list.py +++ b/tests/regressiontests/generic_views/list.py @@ -159,6 +159,16 @@ class ListViewTests(TestCase): def test_missing_items(self): self.assertRaises(ImproperlyConfigured, self.client.get, '/list/authors/invalid/') + def test_paginated_list_view_does_not_load_entire_table(self): + # Regression test for #17535 + self._make_authors(3) + # 1 query for authors + with self.assertNumQueries(1): + self.client.get('/list/authors/notempty/') + # same as above + 1 query to test if authors exist + 1 query for pagination + with self.assertNumQueries(3): + self.client.get('/list/authors/notempty/paginated/') + def _make_authors(self, n): Author.objects.all().delete() for i in range(n): |
