You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we delete an user, cascade delete will try to delete posts and profile too. When post are deleted, post_delete signal is sent and post_deleted callback is called. This callback update the post_count of the author's profile. Do do that, it call util.get_pybb_profile(instance.user) and here is the problem :
With the default Profile which has an AutoOneToOneField relation with the user, the profile is re-created. So, there is not any error, but once the user and all its posts are deleted, the profile still exists.
With a custom Profile wich use a classic OneToOneField, a DoesNotExists exception is raised because profile has already be deleted.
This is an other good point for #54 : use custom signals instead of default models signals : post_deleted callback should not be called when we batch delete posts (like cascade or via api for eg.). Furthermore, if I delete 1 000 posts from one user, his post_count will be recalculated 1 000 times (so 2 000 extra SQL queries will be performed instead of one)
The text was updated successfully, but these errors were encountered:
Hi,
When we delete an user, cascade delete will try to delete posts and profile too. When post are deleted, post_delete signal is sent and post_deleted callback is called. This callback update the post_count of the author's profile. Do do that, it call
util.get_pybb_profile(instance.user)
and here is the problem :With the default Profile which has an
AutoOneToOneField
relation with the user, the profile is re-created. So, there is not any error, but once the user and all its posts are deleted, the profile still exists.With a custom Profile wich use a classic
OneToOneField
, a DoesNotExists exception is raised because profile has already be deleted.This is an other good point for #54 : use custom signals instead of default models signals :
post_deleted
callback should not be called when we batch delete posts (like cascade or via api for eg.). Furthermore, if I delete 1 000 posts from one user, hispost_count
will be recalculated 1 000 times (so 2 000 extra SQL queries will be performed instead of one)The text was updated successfully, but these errors were encountered: