diff options
| author | brian <bdnettleton@gmail.com> | 2025-01-06 17:50:44 -0800 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-02-06 15:27:26 +0100 |
| commit | b96e4c04b666b1044555d7a32f64e83cbad57b03 (patch) | |
| tree | 56a8e08577c9a8e706b6aeaed919ad4cb30cb288 /tests | |
| parent | 8aea6b802ced18a54f00db71c53e09c643f7514c (diff) | |
[5.2.x] Fixed #36061 -- Added migration support for ManyToManyField.through_fields.
Added through_fields support to ManyToManyField.deconstruct.
Thanks to Simon Charette for pointers and the review.
Backport of b13b8684a04d0bc1081104c5973c62c27dc673b0 from main.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/field_deconstruction/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py index 3b10ee0091..41353cbaaf 100644 --- a/tests/field_deconstruction/tests.py +++ b/tests/field_deconstruction/tests.py @@ -516,6 +516,23 @@ class FieldDeconstructionTests(SimpleTestCase): self.assertEqual(path, "django.db.models.ManyToManyField") self.assertEqual(args, []) self.assertEqual(kwargs, {"to": "auth.permission", "through": "auth.Group"}) + # Test through_fields + field = models.ManyToManyField( + "auth.Permission", + through="auth.Group", + through_fields=("foo", "permissions"), + ) + name, path, args, kwargs = field.deconstruct() + self.assertEqual(path, "django.db.models.ManyToManyField") + self.assertEqual(args, []) + self.assertEqual( + kwargs, + { + "to": "auth.permission", + "through": "auth.Group", + "through_fields": ("foo", "permissions"), + }, + ) # Test custom db_table field = models.ManyToManyField("auth.Permission", db_table="custom_table") name, path, args, kwargs = field.deconstruct() |
