mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[1.11.x] Fixed #27897 -- Fixed crash with 'pk' in ModelAdmin.search_filters.
Backport of 6bc4ff36db from master
This commit is contained in:
committed by
Tim Graham
parent
a95616944b
commit
0cc9175c76
@@ -445,6 +445,21 @@ class ChangeListTests(TestCase):
|
||||
# There's only one Concert instance
|
||||
self.assertEqual(cl.queryset.count(), 1)
|
||||
|
||||
def test_pk_in_search_fields(self):
|
||||
band = Group.objects.create(name='The Hype')
|
||||
Concert.objects.create(name='Woodstock', group=band)
|
||||
|
||||
m = ConcertAdmin(Concert, custom_site)
|
||||
m.search_fields = ['group__pk']
|
||||
|
||||
request = self.factory.get('/concert/', data={SEARCH_VAR: band.pk})
|
||||
cl = ChangeList(request, Concert, *get_changelist_args(m))
|
||||
self.assertEqual(cl.queryset.count(), 1)
|
||||
|
||||
request = self.factory.get('/concert/', data={SEARCH_VAR: band.pk + 5})
|
||||
cl = ChangeList(request, Concert, *get_changelist_args(m))
|
||||
self.assertEqual(cl.queryset.count(), 0)
|
||||
|
||||
def test_no_distinct_for_m2m_in_list_filter_without_params(self):
|
||||
"""
|
||||
If a ManyToManyField is in list_filter but isn't in any lookup params,
|
||||
|
||||
Reference in New Issue
Block a user