Skip to content

Commit

Permalink
Change name to comments in queryset
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jul 4, 2023
1 parent 818c5bc commit f0eb422
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions comments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class CommentList(generics.ListCreateAPIView):
"""
serializer_class = CommentSerializer
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
queryset = Comment.objects.all()
# queryset = Comment.objects.annotate(
# likes_count=Count('likes', distinct=True)
# ).order_by('-created_at')
# queryset = Comment.objects.all()
queryset = Comment.objects.annotate(
likes_count=Count('comments', distinct=True)
).order_by('-created_at')

filter_backends = [DjangoFilterBackend]
filterset_fields = ['post']
Expand All @@ -30,7 +30,7 @@ class CommentDetail(generics.RetrieveUpdateDestroyAPIView):
"""
permission_classes = [IsOwnerOrReadOnly]
serializer_class = CommentDetailSerializer
queryset = Comment.objects.all()
# queryset = Comment.objects.annotate(
# likes_count=Count('likes', distinct=True)
# ).order_by('-created_at')
# queryset = Comment.objects.all()
queryset = Comment.objects.annotate(
likes_count=Count('comments', distinct=True)
).order_by('-created_at')

0 comments on commit f0eb422

Please sign in to comment.