diff options
| author | Hisham Mahmood <45965466+Hisham-Pak@users.noreply.github.com> | 2024-02-15 06:29:49 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-14 22:29:49 -0300 |
| commit | 8db593de05c3516c939b7d4b9eb91e8791f4c79a (patch) | |
| tree | edff850e9b3a91281af88de19cc720aa478b360e /tests/modeladmin/tests.py | |
| parent | c783e7a3a0e411811aba83158d55e4f2f3091ac7 (diff) | |
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.
Diffstat (limited to 'tests/modeladmin/tests.py')
| -rw-r--r-- | tests/modeladmin/tests.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index fad2dfaa1c..de8d26ae46 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): |
