m2m_changed throws unwanted signals on admin site
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
After connecting m2m_changed to a callback, it throws pre_clear,post_clear,pre_add,post_add signals in order anytime model instance is saved (even if there are no changes on the m2m field). pre_add and post_add signals contains all pks added to m2m field, not just added or removed ones. It's still useful when catching post_add signal and see which related objects that object has (eg. when counting how many related objects there are). But it's not possible to see which object has been added or removed... I encountered problem on django admin site. I guess when admin site saves an object it clears all related objects first then adds them one-by-one so it's not possible to detect what has been added/removed.