summaryrefslogtreecommitdiff
path: root/tests/modeladmin
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-01-05 14:08:25 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2024-01-08 14:25:32 +0100
commit4cba6748a640a158a26a0a0d11597b393bdd3883 (patch)
tree30cb0f14090ae6ecab72aabe30dd52bdc27becfc /tests/modeladmin
parent4818a139f74744b3e628bd097caf7f030108c23d (diff)
[5.0.x] Fixed #35087 -- Reallowed filtering against foreign keys not listed in ModelAdmin.list_filters.
Regression in f80669d2f5a5f1db9e9b73ca893fefba34f955e7. Backport of a9094ec1f43dca7f2a649327afcd5e6226b4959c from main
Diffstat (limited to 'tests/modeladmin')
-rw-r--r--tests/modeladmin/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py
index 1a9dbdb7cb..dce91b23e4 100644
--- a/tests/modeladmin/tests.py
+++ b/tests/modeladmin/tests.py
@@ -163,6 +163,20 @@ class ModelAdminTests(TestCase):
)
@isolate_apps("modeladmin")
+ def test_lookup_allowed_for_local_fk_fields(self):
+ class Country(models.Model):
+ pass
+
+ class Place(models.Model):
+ country = models.ForeignKey(Country, models.CASCADE)
+
+ class PlaceAdmin(ModelAdmin):
+ pass
+
+ ma = PlaceAdmin(Place, self.site)
+ self.assertIs(ma.lookup_allowed("country", "1", request), True)
+
+ @isolate_apps("modeladmin")
def test_lookup_allowed_non_autofield_primary_key(self):
class Country(models.Model):
id = models.CharField(max_length=2, primary_key=True)