Ticket #22183: patch.diff

File patch.diff, 1.2 KB (added by apollo13, 15 months ago)
  • django/db/backends/schema.py

    diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py
    index 638ae08..dfe7d47 100644
    a b class BaseDatabaseSchemaEditor(object): 
    262262            })
    263263        # Make M2M tables
    264264        for field in model._meta.local_many_to_many:
    265             self.create_model(field.rel.through)
     265            if field.rel.through._meta.auto_created:
     266                self.create_model(field.rel.through)
    266267
    267268    def delete_model(self, model):
    268269        """
  • django/db/models/fields/related.py

    diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
    index 3c022d6..8dd75ba 100644
    a b class ManyToManyField(RelatedField): 
    19961996            kwargs['to'] = self.rel.to
    19971997        else:
    19981998            kwargs['to'] = "%s.%s" % (self.rel.to._meta.app_label, self.rel.to._meta.object_name)
     1999        if getattr(self.rel, 'through', None) is not None:
     2000            kwargs['through'] = self.rel.through
    19992001        # If swappable is True, then see if we're actually pointing to the target
    20002002        # of a swap.
    20012003        swappable_setting = self.swappable_setting
Back to Top