Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #22183: Don't make a table for M2Ms with through=

  • Loading branch information...
commit 1562b9896f8f614ef40fd032b1ec777280b377c1 1 parent 34236ef
Andrew Godwin andrewgodwin authored
3  django/db/backends/schema.py
View
@@ -262,7 +262,8 @@ def create_model(self, model):
})
# Make M2M tables
for field in model._meta.local_many_to_many:
- self.create_model(field.rel.through)
+ if field.rel.through._meta.auto_created:
+ self.create_model(field.rel.through)
def delete_model(self, model):
"""
2  django/db/models/fields/related.py
View
@@ -2032,6 +2032,8 @@ def deconstruct(self):
kwargs['to'] = self.rel.to
else:
kwargs['to'] = "%s.%s" % (self.rel.to._meta.app_label, self.rel.to._meta.object_name)
+ if getattr(self.rel, 'through', None) is not None:
+ kwargs['through'] = self.rel.through
# If swappable is True, then see if we're actually pointing to the target
# of a swap.
swappable_setting = self.swappable_setting
Please sign in to comment.
Something went wrong with that request. Please try again.