@login_required
def like_post(request):
if 'pk' and 'user_id' in request.GET:
idpost = int(request.GET.get('pk'));
idusr = int(request.GET.get('user_id'));
message = UserLikes(
id_post = idpost,
user_id = idusr,
)
message.save()
post = Posts.objects.get(pk=idpost)
if post:
likes = post.count_plus + 1
post.count_plus = likes
post.save()
return HttpResponse(likes)
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<span class="likes" data-postid="{{one_post.pk}}" >
<i class="glyphicon glyphicon-thumbs-up"></i>
</span>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<center>share</center>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<span class="dislikes pull-right" data-postid="{{one_post.pk}}">
<i class="glyphicon glyphicon-thumbs-down"></i>
</span>
</div>
except Posts.DoesNotExist:
code