Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def like_comment(request, pk):
- comment = get_object_or_404(Comment, id=request.POST.get('comment_id'))
- liked_com = False
- if comment.likes.filter(id=request.user.id).exists():
- comment.likes.remove(request.user)
- liked_com = False
- else:
- comment.likes.add(request.user)
- liked_com = True
- return HttpResponseRedirect(reverse('post-detail', args=[str(pk)]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement