我正在尝试获取特定帖子评论的用户。
if User in Post.comments:
part = User.id == Comment.user_id
users = list(User.query.filter(part))
user = User.query.filter_by(username=users)
form = CommentForm()
form2 = ReplyForm()
if form.validate_on_submit():
comment = Comment(content=form.content.data, author=current_user, post_id=post_id)
comment.save()
flash('Your comment has been created!', 'success')
return redirect(url_for('posts.view_comment', post_id=post.id))
return render_template('view_comment.html', form=form, form2=form2, comments=comments, user=user, users=users, title=post.title, post=post, )