class Like(models.Model): user = models.ForeignKey(User) post = models.ForeignKey(Posts) created = models.DateTimeField(auto_now_add=True) def __unicode__(self): return self.user
def like(request, post_id): p = Posts.objects.get() number_of_likes = p.like_set.all().count() new_hipe, created = Hipe.objects.get_or_create(user=request.user, post_id=post_id) render_to_response('posts/wall.html',locals(),context_instance=RequestContext(request)) def post_detail(request, id): post_details = get_object_or_404(Posts, pk=id) user_likes_this = post.like_set.filter(user=request.user) and True or False return render_to_response('posts/wall.html',locals(),context_instance=RequestContext(request))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)