Permalink
Browse files

Add comment to usage of m2m_reverse_field_name

  • Loading branch information...
1 parent 49dc1e7 commit 3a338d00ec0d32d54faa0bf88409d02638eae60d @andrewgodwin andrewgodwin committed Sep 24, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 django/db/backends/schema.py
@@ -591,6 +591,8 @@ def _alter_many_to_many(self, model, old_field, new_field, strict):
# 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],
)

0 comments on commit 3a338d0

Please sign in to comment.