mirror of
https://github.com/django/django.git
synced 2025-11-20 03:30:00 +00:00
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.
This commit is contained in:
parent
2598b371a9
commit
b13b8684a0
3 changed files with 20 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue