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:24 -0700
commitb25aee3b7bef07dd07bed2209efcdf1a8146112c (patch)
treecce493813070db85fffbadad5d91ee9d23a46e70 /django
parent5ea34f3f86af307e1a1c02b49136f51a4f63da88 (diff)
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,
))