diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-01-27 11:49:55 +0000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-01-27 11:49:55 +0000 |
| commit | 6758a9c0fc34dc9944895b98045d2b26c8147ea2 (patch) | |
| tree | 1eb84a5767e2cdc7828e1ad1702767118187292e | |
| parent | dfa28981ced2a6c005cc3c12fdc6b560080818a0 (diff) | |
Fixed #21872: Not detecting dependencies from M2M fields
| -rw-r--r-- | django/db/migrations/autodetector.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index df49088a62..6037c37df5 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -72,8 +72,13 @@ class MigrationAutodetector(object): if field.rel: if field.rel.to: related_fields.append((field.name, field.rel.to._meta.app_label, field.rel.to._meta.model_name)) - if hasattr(field.rel, "through") and not field.rel.though._meta.auto_created: + if hasattr(field.rel, "through") and not field.rel.through._meta.auto_created: related_fields.append((field.name, field.rel.through._meta.app_label, field.rel.through._meta.model_name)) + for field in new_apps.get_model(app_label, model_name)._meta.local_many_to_many: + if field.rel.to: + related_fields.append((field.name, field.rel.to._meta.app_label, field.rel.to._meta.model_name)) + if hasattr(field.rel, "through") and not field.rel.through._meta.auto_created: + related_fields.append((field.name, field.rel.through._meta.app_label, field.rel.through._meta.model_name)) if related_fields: pending_add[app_label, model_name] = related_fields else: |
