mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #35056 -- Fixed system check crash on reverse m2m relations with related_name in ModelAdmin.filter_horizontal/vertical.
Thanks Thomas Feldmann for the report.
Regression in 107865780a.
This commit is contained in:
@@ -322,6 +322,24 @@ class FilterVerticalCheckTests(CheckTestCase):
|
||||
"admin.E020",
|
||||
)
|
||||
|
||||
@isolate_apps("modeladmin")
|
||||
def test_invalid_reverse_m2m_field_with_related_name(self):
|
||||
class Contact(Model):
|
||||
pass
|
||||
|
||||
class Customer(Model):
|
||||
contacts = ManyToManyField("Contact", related_name="customers")
|
||||
|
||||
class TestModelAdmin(ModelAdmin):
|
||||
filter_vertical = ["customers"]
|
||||
|
||||
self.assertIsInvalid(
|
||||
TestModelAdmin,
|
||||
Contact,
|
||||
"The value of 'filter_vertical[0]' must be a many-to-many field.",
|
||||
"admin.E020",
|
||||
)
|
||||
|
||||
@isolate_apps("modeladmin")
|
||||
def test_invalid_m2m_field_with_through(self):
|
||||
class Artist(Model):
|
||||
@@ -384,6 +402,24 @@ class FilterHorizontalCheckTests(CheckTestCase):
|
||||
"admin.E020",
|
||||
)
|
||||
|
||||
@isolate_apps("modeladmin")
|
||||
def test_invalid_reverse_m2m_field_with_related_name(self):
|
||||
class Contact(Model):
|
||||
pass
|
||||
|
||||
class Customer(Model):
|
||||
contacts = ManyToManyField("Contact", related_name="customers")
|
||||
|
||||
class TestModelAdmin(ModelAdmin):
|
||||
filter_horizontal = ["customers"]
|
||||
|
||||
self.assertIsInvalid(
|
||||
TestModelAdmin,
|
||||
Contact,
|
||||
"The value of 'filter_horizontal[0]' must be a many-to-many field.",
|
||||
"admin.E020",
|
||||
)
|
||||
|
||||
@isolate_apps("modeladmin")
|
||||
def test_invalid_m2m_field_with_through(self):
|
||||
class Artist(Model):
|
||||
|
||||
Reference in New Issue
Block a user