def make_comment(comment_form): new_comment = Comments() new_comment.author = comment_form.cleaned_data['fusername'] new_comment.author_email = comment_form.cleaned_data['femail'] new_comment.author_url = comment_form.cleaned_data['fwebsite'] new_comment.content = comment_form.cleaned_data['fmessage'] new_comment.post_id = 0 new_comment.parent_id = 0 new_comment.user_id = 0 new_comment.author_ip = '192.168.1.1' new_comment.save()
def post(self, request, slug,*arg, **kwargs ): context = self.get_context_data(slug, **kwargs) form = CommentAddForm(request.POST) if form.is_valid(): #add a new comment post posts = Posts.all().filter("is_active =", True).filter("slug =", slug).get() comment = Comments(title=form.cleaned_data['title'], body=form.cleaned_data['body'], post=posts) if form.cleaned_data['answer']: comment.answer = Comments.get_by_id(int(form.cleaned_data['answer'])) if request.user: comment.author = request.user comment.put() return redirect('blog:post', slug=slug) context['form'] = form return self.render_to_response(context)