From 3a338d00ec0d32d54faa0bf88409d02638eae60d Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 24 Sep 2012 13:17:38 +0100 Subject: [PATCH] Add comment to usage of m2m_reverse_field_name --- django/db/backends/schema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py index 960fd7035d..5a5932abeb 100644 --- a/django/db/backends/schema.py +++ b/django/db/backends/schema.py @@ -591,6 +591,8 @@ class BaseDatabaseSchemaEditor(object): # Repoint the FK to the other side self.alter_field( new_field.rel.through, + # We need the field that points to the target model, so we can tell alter_field to change it - + # this is m2m_reverse_field_name() (as opposed to m2m_field_name, which points to our model) old_field.rel.through._meta.get_field_by_name(old_field.m2m_reverse_field_name())[0], new_field.rel.through._meta.get_field_by_name(new_field.m2m_reverse_field_name())[0], )