mirror of
https://github.com/django/django.git
synced 2025-10-25 22:56:12 +00:00
[5.0.x] Fixed #35020 -- Fixed ModelAdmin.lookup_allowed() for non-autofield primary keys.
Thanks Joshua Goodwin for the report. Regression in45ecd9acca. Backport off80669d2f5from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
da2475a217
commit
454fd50efb
@@ -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