def newcomment(postId): form = CommentForm() post = Post.objects.get(pk=postId) if form.validate_on_submit(): newComment = Comment(comment=form.comment.data, user=ObjectId(session['currUserId']), post=post.id) newComment.save() newComment.reload() return redirect('/post/' + postId) return render_template('commentform.html', post=post, form=form)
def post(postId): post = Post.objects.get(pk=postId) comments = Comment.objects(post=postId) return render_template('post.html',post=post,comments=comments)