From 3a54e64ef7c14946dd072ddc26666f4ab9551fe0 Mon Sep 17 00:00:00 2001 From: Hisham Mahmood <45965466+Hisham-Pak@users.noreply.github.com> Date: Thu, 15 Feb 2024 06:29:49 +0500 Subject: [5.0.x] Fixed #35173 -- Fixed ModelAdmin.lookup_allowed() for lookups on foreign keys when not included in ModelAdmin.list_filter. Regression in f80669d2f5a5f1db9e9b73ca893fefba34f955e7. Thanks Sarah Boyce for the review. Backport of 8db593de05c3516c939b7d4b9eb91e8791f4c79a from main --- tests/modeladmin/tests.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/modeladmin') diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index dce91b23e4..3fd176ce7a 100644 --- a/tests/modeladmin/tests.py +++ b/tests/modeladmin/tests.py @@ -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): -- cgit v1.3