def article(id): comment_form = CommentsCreateForm() article = db.session.query(Articles).filter(Articles.id == id).first() creator = db.session.query(User).filter(User.id == article.creator).first() comments = db.session.query(Comment).filter( Comment.article_id == id).all() # список кометариев if comment_form.validate_on_submit(): comment = Comment() comment.comment_creator = current_user.id comment.article_id = id comment.content = comment_form.text.data current_user.comment.append(comment) db.session.commit() return render_template("news_template.html", article=article, creator=creator, comments=comments, form=comment_form) return render_template("news_template.html", article=article, creator=creator, comments=comments, form=comment_form)