Opened 15 years ago
Last modified 15 years ago
#13022 closed
when saving a model with m2m field in the admin, 'clear' and 'add' m2m_changed signals are fired even when there is no change. — at Initial Version
Reported by: | benc | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | signals, m2m_changed | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
I've built a simple test project with one app and two models, Model1 and Model2.
Model2 has a ManyToManyField to Model1.
I've created one Model1 instance and one Model2 instance with a relation to the Model1 instance.
When saving the Model2 instance in the admin, even without a change, m2m_changed fires twice.
I think it shouldn't fire at all when the admin form is saved without a change:
sender <class 'testproject.testapp.models.Model2_models1'>
instance Model2 object
action clear
model <class 'testproject.testapp.models.Model1'>
sender <class 'testproject.testapp.models.Model2_models1'>
instance Model2 object
action add
model <class 'testproject.testapp.models.Model1'>