summaryrefslogtreecommitdiff
path: root/tests/model_options
diff options
context:
space:
mode:
authorDavid Wobrock <david.wobrock@gmail.com>2022-05-17 16:13:35 +0200
committerDavid Wobrock <david.wobrock@gmail.com>2022-07-12 09:04:31 +0200
commita6385b382e05a614a99e5a5913d8e631823159a2 (patch)
tree63e10468533956576c76593b7dba26a03c0058da /tests/model_options
parent4f284115a9181990f713d5167b25628fa171a5e4 (diff)
downloaddjango-a6385b382e05a614a99e5a5913d8e631823159a2.tar.gz
Fixed #27236 -- Deprecated Meta.index_together in favor of Meta.indexes.
This also deprecates AlterIndexTogether migration operation.
Diffstat (limited to 'tests/model_options')
-rw-r--r--tests/model_options/test_index_together_deprecation.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/model_options/test_index_together_deprecation.py b/tests/model_options/test_index_together_deprecation.py
new file mode 100644
index 0000000000..9b5362a924
--- /dev/null
+++ b/tests/model_options/test_index_together_deprecation.py
@@ -0,0 +1,20 @@
+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"]