summaryrefslogtreecommitdiff
path: root/tests/modeladmin
diff options
context:
space:
mode:
authorHisham Mahmood <45965466+Hisham-Pak@users.noreply.github.com>2024-02-15 06:29:49 +0500
committerNatalia <124304+nessita@users.noreply.github.com>2024-02-15 08:18:27 -0300
commit3a54e64ef7c14946dd072ddc26666f4ab9551fe0 (patch)
tree90b52edd3d412c5176581df5730c1fdee961e43e /tests/modeladmin
parent1ba5afa0f21f10843bb530b443687e07a511516a (diff)
[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
Diffstat (limited to 'tests/modeladmin')
-rw-r--r--tests/modeladmin/tests.py14
1 files changed, 13 insertions, 1 deletions
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):