mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #22356 -- Added a check to make sure unique_together fields are local.
This commit is contained in:
parent
17c1884456
commit
0bcc92c691
3 changed files with 38 additions and 0 deletions
|
@ -76,6 +76,30 @@ class IndexTogetherTests(IsolatedModelsTestCase):
|
|||
]
|
||||
self.assertEqual(errors, expected)
|
||||
|
||||
def test_pointing_to_non_local_field(self):
|
||||
class Foo(models.Model):
|
||||
field1 = models.IntegerField()
|
||||
|
||||
class Bar(Foo):
|
||||
field2 = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
index_together = [
|
||||
["field2", "field1"],
|
||||
]
|
||||
|
||||
errors = Bar.check()
|
||||
expected = [
|
||||
Error(
|
||||
("'index_together' refers to field 'field1' which is not "
|
||||
"local to model 'Bar'."),
|
||||
hint=("This issue may be caused by multi-table inheritance."),
|
||||
obj=Bar,
|
||||
id='models.E016',
|
||||
),
|
||||
]
|
||||
self.assertEqual(errors, expected)
|
||||
|
||||
def test_pointing_to_m2m_field(self):
|
||||
class Model(models.Model):
|
||||
m2m = models.ManyToManyField('self')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue