def comment_modify(request, comment_pk):
# get_object_or_404? ???? Comment?? ????
comment = get_object_or_404(Comment, pk=comment_pk)
next = request.GET.get('next')
if request.method == 'POST':
# Form? ??? ??? update?? (data? ??? ??? update?)
form = CommentForm(data=request.POST, instance=comment)
if form.is_valid():
form.save()
if next:
return redirect(next)
return redirect('post:post_detail', post_pk=comment.post.pk)
else:
# CommentForm? ?? comment????? ??? ?? bound form
form = CommentForm(instance=comment)
context = {
'form': form,
}
return render(request, 'post/comment_modify.html', context)
评论列表
文章目录