Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.6.x] Fixed #21510 -- Readded search reset link in changelist searc…

…h bar

Thanks moritz.pfeiffer at alp-phone.ch for the report and
Tim Graham for the initial patch.
Backport of c7c6474 from master.
  • Loading branch information...
commit d32637d81b6b4adf6440bead756fb5a063e4d28d 1 parent 64483b4
@claudep claudep authored
View
2  django/contrib/admin/views/main.py
@@ -223,7 +223,7 @@ def get_results(self, request):
# Perform a slight optimization:
# full_result_count is equal to paginator.count if no filters
# were applied
- if self.get_filters_params():
+ if self.get_filters_params() or self.params.get(SEARCH_VAR):
full_result_count = self.root_queryset.count()
else:
full_result_count = result_count
View
2  docs/releases/1.6.1.txt
@@ -47,3 +47,5 @@ Bug fixes
* Fixed password hash upgrade when changing the iteration count (#21535).
* Fixed a bug in the debug view when the urlconf only contains one element
(#21530).
+* Re-added missing search result count and reset link in changelist admin view
+ (#21510).
View
15 tests/admin_views/tests.py
@@ -2242,6 +2242,15 @@ def test_pluggable_search(self):
self.assertContains(response, "\n1 pluggable search person\n")
self.assertContains(response, "Amy")
+ def test_reset_link(self):
+ """
+ Test presence of reset link in search bar ("1 result (_x total_)").
+ """
+ response = self.client.get('/test_admin/admin/admin_views/person/?q=Gui')
+ self.assertContains(response,
+ """<span class="small quiet">1 result (<a href="?">3 total</a>)</span>""",
+ html=True)
+
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
class AdminInheritedInlinesTest(TestCase):
@@ -2665,17 +2674,17 @@ def test_changelist_view_count_queries(self):
resp = self.client.get('/test_admin/admin/admin_views/person/')
self.assertEqual(resp.context['selection_note'], '0 of 2 selected')
self.assertEqual(resp.context['selection_note_all'], 'All 2 selected')
- with self.assertNumQueries(4):
+ # here one more count(*) query will run, because filters were applied
+ with self.assertNumQueries(5):
extra = {'q': 'not_in_name'}
resp = self.client.get('/test_admin/admin/admin_views/person/', extra)
self.assertEqual(resp.context['selection_note'], '0 of 0 selected')
self.assertEqual(resp.context['selection_note_all'], 'All 0 selected')
- with self.assertNumQueries(4):
+ with self.assertNumQueries(5):
extra = {'q': 'person'}
resp = self.client.get('/test_admin/admin/admin_views/person/', extra)
self.assertEqual(resp.context['selection_note'], '0 of 2 selected')
self.assertEqual(resp.context['selection_note_all'], 'All 2 selected')
- # here one more count(*) query will run, because filters were applied
with self.assertNumQueries(5):
extra = {'gender__exact': '1'}
resp = self.client.get('/test_admin/admin/admin_views/person/', extra)
Please sign in to comment.
Something went wrong with that request. Please try again.