|
@@ -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):
|