summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-03-08 15:57:25 -0800
committerAndrew Godwin <andrew@aeracode.org>2014-03-08 15:58:04 -0800
commit6b078044745ee3c665051a886021c6fd1f6873b6 (patch)
tree7b2c7aa7cca1eec72db7247bd58f2b215bbff47e /django
parentcdf6eba1816669bd77a28da903d931b5a4b15992 (diff)
Fixed #22183: Through M2Ms now correctly handled
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/schema.py3
-rw-r--r--django/db/models/fields/related.py5
2 files changed, 7 insertions, 1 deletions
diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py
index 862b22f901..ef53ac1608 100644
--- a/django/db/backends/schema.py
+++ b/django/db/backends/schema.py
@@ -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):
"""
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index e4c055ff63..41c020f509 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -2032,6 +2032,11 @@ 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:
+ if isinstance(self.rel.through, six.string_types):
+ kwargs['through'] = self.rel.through
+ else:
+ kwargs['through'] = "%s.%s" % (self.rel.through._meta.app_label, self.rel.through._meta.object_name)
# If swappable is True, then see if we're actually pointing to the target
# of a swap.
swappable_setting = self.swappable_setting