Code

Ticket #10647: managedm2m_v2.diff

File managedm2m_v2.diff, 701 bytes (added by jbronn, 5 years ago)

Omit ManyToMany table creation only if both fields are managed.

Line 
1Index: django/db/backends/creation.py
2===================================================================
3--- django/db/backends/creation.py      (revision 10327)
4+++ django/db/backends/creation.py      (working copy)
5@@ -140,7 +140,8 @@
6         "Return the CREATE TABLE statments for all the many-to-many tables defined on a model"
7         output = []
8         for f in model._meta.local_many_to_many:
9-            output.extend(self.sql_for_many_to_many_field(model, f, style))
10+            if model._meta.managed or f.rel.to._meta.managed:
11+                output.extend(self.sql_for_many_to_many_field(model, f, style))
12         return output
13 
14     def sql_for_many_to_many_field(self, model, f, style):