Generic relations should be counted as children when deleting to avoid problems with post_delete signal
|Reported by:||rfugger||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When deleting an object and its related objects, generically-related models aren't counted as children in the delete order, and so may be deleted after the original model is deleted. This causes problems when the post_delete signal from the generic relation tries to update its parent.
For example, if a model Article has a generic relation to a Vote model, and the post_delete signal from Vote recomputes the parent Article's cached vote tally and saves the Article, then deleting the Article will fail if the Votes get deleted after the Article.
The solution is to deleted generically related children first.
A workaround is to disconnect the post delete signal when deleting the parent, and reconnect after.
Change History (9)
comment:1 Changed 5 years ago by rfugger
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 5 years ago by russellm
- Resolution set to wontfix
- Status changed from new to closed