mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #35020 -- Fixed ModelAdmin.lookup_allowed() for non-autofield primary keys.
Thanks Joshua Goodwin for the report.
Regression in 45ecd9acca.
This commit is contained in:
committed by
Mariusz Felisiak
parent
00ef74376e
commit
f80669d2f5
@@ -162,6 +162,20 @@ class ModelAdminTests(TestCase):
|
||||
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)
|
||||
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user