From 28e5b665189548557993b522e3bd7adeed3f62ea Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Tue, 10 Apr 2012 20:05:46 +0000 Subject: Fixed #18087 -- Prevented date-based generic views from loading entire tables in memory when pagination is enabled. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17893 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/generic_views/dates.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py index 652f66b7f1..9de817acc2 100644 --- a/tests/regressiontests/generic_views/dates.py +++ b/tests/regressiontests/generic_views/dates.py @@ -78,6 +78,15 @@ class ArchiveIndexViewTests(TestCase): self.assertEqual(res.context['page_obj'].number, 2) self.assertEqual(list(res.context['latest']), list(Book.objects.all()[10:20])) + def test_paginated_archive_view_does_not_load_entire_table(self): + # Regression test for #18087 + self._make_books(20, base_date=datetime.date.today()) + # 1 query for years list + 1 query for books + with self.assertNumQueries(2): + self.client.get('/dates/books/') + # same as above + 1 query to test if books exist + with self.assertNumQueries(3): + self.client.get('/dates/books/paginated/') class YearArchiveViewTests(TestCase): fixtures = ['generic-views-test-data.json'] -- cgit v1.3