def remove_follower(self, request, pk=None):
guid = request.data.get("guid")
try:
target_profile = Profile.objects.get(guid=guid)
except Profile.DoesNotExist:
raise PermissionDenied("Profile given does not exist.")
profile = self.get_object()
if profile.guid == guid:
raise ValidationError("Cannot unfollow self!")
profile.following.remove(target_profile)
return Response({"status": "Follower removed."})
评论列表
文章目录