Fixed #35173 -- Fixed ModelAdmin.lookup_allowed() for lookups on foreign keys when not included in ModelAdmin.list_filter.

Regression in f80669d2f5.

Thanks Sarah Boyce for the review.
This commit is contained in:
Hisham Mahmood 2024-02-15 06:29:49 +05:00 committed by GitHub
parent c783e7a3a0
commit 8db593de05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 12 deletions

View file

@ -174,7 +174,19 @@ class ModelAdminTests(TestCase):
pass
ma = PlaceAdmin(Place, self.site)
self.assertIs(ma.lookup_allowed("country", "1", request), True)
cases = [
("country", "1"),
("country__exact", "1"),
("country__id", "1"),
("country__id__exact", "1"),
("country__isnull", True),
("country__isnull", False),
("country__id__isnull", False),
]
for lookup, lookup_value in cases:
with self.subTest(lookup=lookup):
self.assertIs(ma.lookup_allowed(lookup, lookup_value, request), True)
@isolate_apps("modeladmin")
def test_lookup_allowed_non_autofield_primary_key(self):