diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
index df0fd9f..7878873 100644
a
|
b
|
class ChangeList(object):
|
104 | 104 | |
105 | 105 | # Get the total number of objects, with no admin filters applied. |
106 | 106 | # Perform a slight optimization: Check to see whether any filters were |
107 | | # given. If not, use paginator.hits to calculate the number of objects, |
108 | | # because we've already done paginator.hits and the value is cached. |
109 | | if not self.query_set.query.where: |
| 107 | # given by the user, if any came from ModelAdmin.queryset() we don't |
| 108 | #consider them here. If not, use paginator.hits to calculate the number |
| 109 | # of objects, because we've already done paginator.hits and the value |
| 110 | # is cached. |
| 111 | if not set(self.params) - set([ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR]): |
110 | 112 | full_result_count = result_count |
111 | 113 | else: |
112 | 114 | full_result_count = self.root_query_set.count() |
… |
… |
class ChangeList(object):
|
191 | 193 | # Naked except! Because we don't have any other way of validating "params". |
192 | 194 | # They might be invalid if the keyword arguments are incorrect, or if the |
193 | 195 | # values are not in the correct type, so we might get FieldError, ValueError, |
194 | | # ValicationError, or ? from a custom field that raises yet something else |
| 196 | # ValicationError, or ? from a custom field that raises yet something else |
195 | 197 | # when handed impossible data. |
196 | 198 | except: |
197 | 199 | raise IncorrectLookupParameters |
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 0c7fbc0..8ceeb4d 100644
a
|
b
|
|
2 | 2 | |
3 | 3 | import re |
4 | 4 | import datetime |
5 | | from django.core.files import temp as tempfile |
6 | | from django.test import TestCase |
7 | | from django.contrib.auth.models import User, Permission |
8 | | from django.contrib.contenttypes.models import ContentType |
| 5 | |
| 6 | from django.conf import settings |
| 7 | from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME |
9 | 8 | from django.contrib.admin.models import LogEntry, DELETION |
10 | 9 | from django.contrib.admin.sites import LOGIN_FORM_KEY |
11 | 10 | from django.contrib.admin.util import quote |
12 | | from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME |
| 11 | from django.contrib.auth.models import User, Permission |
| 12 | from django.contrib.contenttypes.models import ContentType |
| 13 | from django.core.files import temp as tempfile |
| 14 | from django.db import connection |
| 15 | from django.test import TestCase |
13 | 16 | from django.utils import formats |
14 | 17 | from django.utils.cache import get_max_age |
15 | 18 | from django.utils.html import escape |
… |
… |
class AdminCustomQuerysetTest(TestCase):
|
1289 | 1292 | else: |
1290 | 1293 | self.assertNotContains(response, 'Primary key = %s' % i) |
1291 | 1294 | |
| 1295 | def test_changelist_view_count_queries(self): |
| 1296 | old_debug = settings.DEBUG |
| 1297 | settings.DEBUG = True |
| 1298 | num_queries = len(connection.queries) |
| 1299 | response = self.client.get('/test_admin/admin/admin_views/emptymodel/') |
| 1300 | # The page should do 5 queries: 1 for the session, 1 for the user, 1 |
| 1301 | # for the count, 1 for user messages, and 1 for the objects on the page |
| 1302 | self.assertEqual(len(connection.queries), num_queries+5, len(connection.queries) - num_queries) |
| 1303 | |
1292 | 1304 | def test_change_view(self): |
1293 | 1305 | for i in self.pks: |
1294 | 1306 | response = self.client.get('/test_admin/admin/admin_views/emptymodel/%s/' % i) |