Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to handle proxy model and multiple M2M situations #270

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rgegriff
Copy link

I ran into some issues dealing with M2M relationships resulting in "null" being recorded as the fieldname for adds/removes on changes to proxy models which led me to #207

This PR re-writes get_m2m_field_name to use the sender that gets passed to the signal handler, which happens to be the through model.

Given the through model, the changed instance, and the added model; we can uniquely determine which field on the instance model was changed, even if the originating model has multiple M2M relationships with the remote model (since each will use a different intermediate model).

There was also an issue that I didn't see in the issue tracker that came up for me; if the changed instance was a proxy model then get_m2m_field_name would return None . This also resolves that issue since we are searching for the field directly

@rgegriff
Copy link
Author

Added some tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant