Ticket #23101: 23101.diff

File 23101.diff, 1.5 KB (added by abraham.martin, 10 years ago)

fix

  • django/db/models/fields/related.py

    diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
    index 78815c2..2fb6af6 100644
    a b class ManyToManyField(RelatedField):  
    20882088    def deconstruct(self):
    20892089        name, path, args, kwargs = super(ManyToManyField, self).deconstruct()
    20902090        # Handle the simpler arguments
     2091        if self.db_table is not None:
     2092            kwargs['db_table'] = self.db_table
    20912093        if self.rel.db_constraint is not True:
    20922094            kwargs['db_constraint'] = self.rel.db_constraint
    20932095        if "help_text" in kwargs:
  • tests/field_deconstruction/tests.py

    diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py
    index 04d4c6a..9a330b2 100644
    a b class FieldDeconstructionTests(TestCase):  
    271271        self.assertEqual(path, "django.db.models.ManyToManyField")
    272272        self.assertEqual(args, [])
    273273        self.assertEqual(kwargs, {"to": "auth.Permission", "through": "auth.Group"})
     274        # Test custom db_table
     275        field = models.ManyToManyField("auth.Permission", db_table="custom_table")
     276        name, path, args, kwargs = field.deconstruct()
     277        self.assertEqual(path, "django.db.models.ManyToManyField")
     278        self.assertEqual(args, [])
     279        self.assertEqual(kwargs, {"to": "auth.Permission", "db_table": "custom_table"})
    274280
    275281    @override_settings(AUTH_USER_MODEL="auth.Permission")
    276282    def test_many_to_many_field_swapped(self):
Back to Top