mirror of
https://github.com/django/django.git
synced 2025-12-23 09:19:27 +00:00
Fixed #22476: Couldn't alter attributes on M2Ms with through= set
This commit is contained in:
parent
5ea34f3f86
commit
b25aee3b7b
4 changed files with 49 additions and 3 deletions
|
|
@ -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,
|
||||
))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue