Beispiel #1
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')
Beispiel #2
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")
Beispiel #3
0
 def post(self, request, comment_id):
     comment = Comment.objects.get(id=comment_id)
     form = CommentForm(instance=comment, data=request.POST)
     if form.is_valid():
         comment.save()
         return redirect("hello")
     form = CommentForm(instance=comment)
     return render(request, "update_comment.html", {
         "form": form,
         "comment_id": comment_id
     })
Beispiel #4
0
 def post(self, request, comment_id):
     comment = Comment.objects.get(id=comment_id)
     cf = CommentForm(instance=comment, date=request.POST)
     if cf.is_valid():
         cf.save
     return redirect('hello')