summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
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,
))