Beispiel #1
0
def post_detail(request, id, showComments=False):
     posts=Post.objects.get(pk=id)
     comments=Comment.objects.filter(comment_post=id)
     if request.method == 'POST':
          comment=Comment(comment_post=posts)
          #assigning the logged in user to the comment
          comment.comment_author=request.user	
          form = CommentForm(request.POST,instance=comment)
          if form.is_valid():
	       form.save()
	  return HttpResponseRedirect(request.path)
     else:
               form = CommentForm()

     
     t = loader.get_template('blog/post_detail.html')  
     c = Context({'post':posts,'comment':comments,'form':form,'user':request.user })    	
     return HttpResponse(t.render(c))