if request method POST form CommentForm request POST if form is_valid

1
2
3
4
5
6
if request.method == 'POST':
form = CommentForm(request.POST)
if form.is_valid():
comment_body = form.cleaned_data['body']
comment = Comment(text = comment_body, author = request.user, post = post)
comment.save()