diff options
author | David Wobrock <david.wobrock@gmail.com> | 2022-05-17 16:13:35 +0200 |
---|---|---|
committer | David Wobrock <david.wobrock@gmail.com> | 2022-07-12 09:04:31 +0200 |
commit | a6385b382e05a614a99e5a5913d8e631823159a2 (patch) | |
tree | 63e10468533956576c76593b7dba26a03c0058da /tests/model_options | |
parent | 4f284115a9181990f713d5167b25628fa171a5e4 (diff) | |
download | django-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.py | 20 |
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"] |