1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[5.0.x] Fixed #35087 -- Reallowed filtering against foreign keys not listed in ModelAdmin.list_filters.

Regression in f80669d2f5.

Backport of a9094ec1f4 from main
This commit is contained in:
Sarah Boyce
2024-01-05 14:08:25 +01:00
committed by Mariusz Felisiak
parent 4818a139f7
commit 4cba6748a6
3 changed files with 20 additions and 3 deletions

View File

@@ -162,6 +162,20 @@ class ModelAdminTests(TestCase):
True,
)
@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):