diff --git a/hinghwa-dict-backend/article/views.py b/hinghwa-dict-backend/article/views.py index b2df0065..de5fc410 100644 --- a/hinghwa-dict-backend/article/views.py +++ b/hinghwa-dict-backend/article/views.py @@ -313,17 +313,15 @@ def get(self, request, id) -> JsonResponse: token = token_pass(request.headers) user = token_user(token) - except UnauthorizedException: - return JsonResponse({"comment": comment_all(comment), "me": me}, status=401) + # 获取评论信息 - # 获取评论信息 - try: comment = Comment.objects.get(id=id) is_liked = comment.like_users.filter(id=user.id).exists() is_author = user == comment.user if user else False me = {"is_liked": is_liked, "is_author": is_author} - + except UnauthorizedException: + return JsonResponse({"comment": comment_all(comment), "me": me}, status=401) except Comment.DoesNotExist: raise CommentNotFoundException(id)