【发布时间】:2020-04-28 16:05:19
【问题描述】:
我编写了一个原始 SQL 查询来显示点赞帖子的用户列表,但查询返回的用户列表不仅喜欢当前帖子,还喜欢其他帖子。
这是我写的路线
@app.route('/like/<int:post_id>/viewLikes')
@login_required
def viewLikers(post_id):
post = Post.query.get_or_404(post_id)
result = db.engine.execute("Select username from user, PostLike, Post where user.id=PostLike.users_id and PostLike.post_id=post.id")
return render_template('viewLikes.html', likers=result)
【问题讨论】:
标签: python sql flask flask-sqlalchemy