summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-05-08 10:33:59 -0700
committerAndrew Godwin <andrew@aeracode.org>2014-05-08 10:34:45 -0700
commitf2bf59a5bc373eeb60136f3b3764e156efbc1ea8 (patch)
tree0a27a7e91b2af5f9091d4b967deabec7e54e59da /django
parentbc82c0dbac33ced1a4d6953e8626236ae05af956 (diff)
[1.7.x] Fixed #22476: Couldn't alter attributes on M2Ms with through= set
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/schema.py5
-rw-r--r--django/db/backends/sqlite3/schema.py5
2 files changed, 8 insertions, 2 deletions
diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py
index d0c4639d7f..2a62803a73 100644
--- a/django/db/backends/schema.py
+++ b/django/db/backends/schema.py
@@ -483,8 +483,11 @@ class BaseDatabaseSchemaEditor(object):
new_type = new_db_params['type']
if old_type is None and new_type is None and (old_field.rel.through and new_field.rel.through and old_field.rel.through._meta.auto_created and new_field.rel.through._meta.auto_created):
return self._alter_many_to_many(model, old_field, new_field, strict)
+ elif old_type is None and new_type is None and (old_field.rel.through and new_field.rel.through and not old_field.rel.through._meta.auto_created and not new_field.rel.through._meta.auto_created):
+ # Both sides have through models; this is a no-op.
+ return
elif old_type is None or new_type is None:
- raise ValueError("Cannot alter field %s into %s - they are not compatible types (probably means only one is an M2M with implicit through model)" % (
+ raise ValueError("Cannot alter field %s into %s - they are not compatible types (you cannot alter to or from M2M fields, or add or remove through= on M2M fields)" % (
old_field,
new_field,
))
diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py
index 005d4b13c8..5b6155be47 100644
--- a/django/db/backends/sqlite3/schema.py
+++ b/django/db/backends/sqlite3/schema.py
@@ -148,8 +148,11 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
new_type = new_db_params['type']
if old_type is None and new_type is None and (old_field.rel.through and new_field.rel.through and old_field.rel.through._meta.auto_created and new_field.rel.through._meta.auto_created):
return self._alter_many_to_many(model, old_field, new_field, strict)
+ elif old_type is None and new_type is None and (old_field.rel.through and new_field.rel.through and not old_field.rel.through._meta.auto_created and not new_field.rel.through._meta.auto_created):
+ # Both sides have through models; this is a no-op.
+ return
elif old_type is None or new_type is None:
- raise ValueError("Cannot alter field %s into %s - they are not compatible types (probably means only one is an M2M with implicit through model)" % (
+ raise ValueError("Cannot alter field %s into %s - they are not compatible types (you cannot alter to or from M2M fields, or add or remove through= on M2M fields)" % (
old_field,
new_field,
))