summaryrefslogtreecommitdiff
path: root/tests/modeladmin
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2023-12-06 19:03:41 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-12-07 06:16:35 +0100
commitf80669d2f5a5f1db9e9b73ca893fefba34f955e7 (patch)
tree24b070a845073a362377dfa06c8ec4ee9febe2aa /tests/modeladmin
parent00ef74376e382cf33d6a9529bb9fc1b412e0bc7d (diff)
Fixed #35020 -- Fixed ModelAdmin.lookup_allowed() for non-autofield primary keys.
Thanks Joshua Goodwin for the report. Regression in 45ecd9acca9b36093e274f47b6877a5f79108d9e.
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 ec46b04c2e..e0c4d6e727 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_non_autofield_primary_key(self):
+ class Country(models.Model):
+ id = models.CharField(max_length=2, primary_key=True)
+
+ class Place(models.Model):
+ country = models.ForeignKey(Country, models.CASCADE)
+
+ class PlaceAdmin(ModelAdmin):
+ list_filter = ["country"]
+
+ ma = PlaceAdmin(Place, self.site)
+ self.assertIs(ma.lookup_allowed("country__id__exact", "DE", request), True)
+
+ @isolate_apps("modeladmin")
def test_lookup_allowed_foreign_primary(self):
class Country(models.Model):
name = models.CharField(max_length=256)