flask一个delete键删除一条评论

新手上路,请多包涵

后台从数据库查询出可能要删除的评论后,前端/后端如何控制一个delete键只删除其对应的评论,而不影响其他评论?(使用db.session.delete(),db.session.commit())
后台查询评论部分代码:

comments = Comment.query.all()
lists=[]
if form.validate_on_submit():
        keywords = form.content.data
        for comment in comments:
            if keywords in comment.body:
                #comp   = form.completed.data
                comment_body = comment.body
                com = Comment.query.filter_by(body=comment_body).first()
                postid = com.post_id
                posts = Post.query.filter_by(post_id=postid).first()
                titles = posts.title
                lists.append(dict(comment_body = comment.body, postid = com.post_id, titles = posts.title))
        return render_template('comment_search.htm',form=form,commentss=lists)
阅读 4.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题