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

This commit is contained in:
Andrew Godwin 2014-03-06 11:35:58 -08:00
parent 34236efc5e
commit 1562b9896f
2 changed files with 4 additions and 1 deletions

View File

@ -262,7 +262,8 @@ class BaseDatabaseSchemaEditor(object):
})
# 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):
"""

View File

@ -2032,6 +2032,8 @@ class ManyToManyField(RelatedField):
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