QuerySet.update() bypasses custom Model.save() methods
|Reported by:||emulbreh||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
This is symmetrical to #6915 (and therefore should be handled simmilar). Options:
- iterate the queryset, update and save() each instance individually. Because this would also work for sliced querysets #7298 would deserve a better fix then.
- assert not self.has_custom_save(), "Cannot update a query for a model with a custom save() method.". This will probably break ManyRelated managers.
- only add a big warning to QuerySet.update() and Model.save() doc. This doesn't help at all to solve the issue.
+1 for the first option.
Change History (9)
comment:1 Changed 8 years ago by emulbreh
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 8 years ago by emulbreh
- Triage Stage changed from Unreviewed to Design decision needed
comment:8 Changed 8 years ago by mtredinnick
- Resolution set to fixed
- Status changed from new to closed