def post_deleted(instance, **kwargs): Profile = utils.get_pybb_profile_model() User = compat.get_user_model() try: profile = utils.get_bb_profile(instance.author) except (Profile.DoesNotExist, User.DoesNotExist) as e: # When we cascade delete an user, profile and posts are also deleted pass else: profile.post_count = instance.author.posts.count() profile.save()
def bb_get_profile(*args, **kwargs): try: return utils.get_bb_profile(kwargs.get('user') or args[0]) except: return utils.get_pybb_profile_model().objects.none()