def save(self, commit=True): comment = Comment() comment.text = self.cleaned_data['text'] comment.user = self.user comment.blog = self.post if commit: comment.save() return comment
def add_comment_to_post(request, slug): post = get_object_or_404(Post, slug=slug) if request.method == "POST": comment = Comment() comment.text = request.POST.get("commentBox") comment.post = post comment.comment_user = request.user comment.save() return redirect('post:postlist') else: return redirect('post:postlist')