1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00
django/tests/model_options/test_index_together_deprecation.py
David Wobrock a6385b382e
Fixed #27236 -- Deprecated Meta.index_together in favor of Meta.indexes.
This also deprecates AlterIndexTogether migration operation.
2022-07-12 09:04:31 +02:00

21 lines
688 B
Python

from django.db import models
from django.test import TestCase
from django.utils.deprecation import RemovedInDjango51Warning
class IndexTogetherDeprecationTests(TestCase):
def test_warning(self):
msg = (
"'index_together' is deprecated. Use 'Meta.indexes' in "
"'model_options.MyModel' instead."
)
with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
class MyModel(models.Model):
field_1 = models.IntegerField()
field_2 = models.IntegerField()
class Meta:
app_label = "model_options"
index_together = ["field_1", "field_2"]