You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a situation where a specific model has multiple M2M relations to django User model. It may be an edge case, but I noticed that easyaudit reports just the first found m2m relation between my model and User model, no matter which of the M2M relations was altered.
After some digging I found out that this is caused by the fact that utils.get_m2m_field_name() which is called by model_signals.py.m2m_changed() returns the first m2m relation between found between the models even if there are multiple. The only place where the actual changed field can be detected from is in the sender argument to m2m_changed() which is currently being ignored.
As my case might be unusual, I'm not expecting a quick fix as this might be non-trivial. However created the issue in case someone else hits the same problem.
The text was updated successfully, but these errors were encountered:
I believe I am also experiencing this issue, or something similar.
For me, the field name listed in the CRUDEvent's "field_changes" is the string "null". I can look at the CRUDEvent's object_json_repr and grab its m2m_rev_model which is the reverse model's app_label.model_name.
However, many of my models have double m2m relationships with each other, e.g. an Employee has two Location sets, their "Assigned Locations" and their "Supervised Locations". The CRUDEvent does not seem to contain sufficient information for me to see which of those sets was altered.
tl;dr It is quite difficult to see which m2m model was altered, and it is impossible to see which specific m2m relationship was altered.
If anyone has the bandwidth to put up a draft PR, that would be appreciated. Even if you're unsure that you know how to effectively solve it, and even if you haven't added any tests, the contribution (at least pre-merge) is still encouraged and welcome.
I have a situation where a specific model has multiple M2M relations to django User model. It may be an edge case, but I noticed that
easyaudit
reports just the first found m2m relation between my model and User model, no matter which of the M2M relations was altered.After some digging I found out that this is caused by the fact that
utils.get_m2m_field_name()
which is called bymodel_signals.py.m2m_changed()
returns the first m2m relation between found between the models even if there are multiple. The only place where the actual changed field can be detected from is in thesender
argument tom2m_changed()
which is currently being ignored.As my case might be unusual, I'm not expecting a quick fix as this might be non-trivial. However created the issue in case someone else hits the same problem.
The text was updated successfully, but these errors were encountered: