Generic relations should be counted as children when deleting to avoid problems with post_delete signal
|Reported by:||Ryan Fugger||Owned by:||nobody|
|Cc:||Ryan Fugger||Triage Stage:||Unreviewed|
|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 6 years ago by
|Patch needs improvement:||unset|