示例#1
0
 def post(self, request, book_id):
     if request.user.is_authenticated:
         cf = CommentForm(data=request.POST)
         comment = cf.save(commit=False)
         comment.user = request.user
         comment.book_id = book_id
         comment.save()
     return redirect('hello')
示例#2
0
 def post(self, request, id):
     comment = CommentForm(renderer=request, data=request.POST)
     if comment.is_valid():
         new_comment = comment.save(commit=False)
         new_comment.book_id = id
         new_comment.user_id = request.user.id
         new_comment.save()
         comment.save_m2m()
     return redirect('hello')
示例#3
0
 def post(self, request, book_id):
     if request.user.is_authenticated:
         new_comment = CommentForm(request.POST)
         if new_comment.is_valid():
             nc = new_comment.save(commit=False)
             nc.user = request.user
             nc.book_id = book_id
             nc.save()
     return redirect("hello")
示例#4
0
 def post(self, request, comment_id):
     comment = Comment.objects.get(id=comment_id)
     cf = CommentForm(instance=comment, data=request.POST)
     if cf.is_valid():
         cf.save()
     return redirect('hello')