sqlalchemy / flask查询中的类型错误

时间:2015-07-24 00:06:04

标签: python flask sqlalchemy

我想知道我是否可以通过Flask-sqlalchemy和postgres数据库制作的应用程序错误获得一些帮助。我目前有一个年份清单(整数)。列表的元素取决于用户选择的年份。通过列表,我在下面搜索我的数据库中的结果,该结果的财政年度与我的列表中的年份匹配:

@main.route('/searchresults')
def yearresults():
    entries = db.session.query(Post).filter(Post.fiscalyear.in_(list))
    return render_template('yearsearch.html', entries=entries)

然而,当我运行时,我得到了

TypeError: 'type' object is not iterable

错误发生在查询行上(db.session.query(Post).filter ...)

我知道我的代码在我查询某个特定年份时有效,但我试图让它与多个未知数一起工作。我想知道是否有人看到了解决方案或更好的方法来做到这一点。

提前致谢!

1 个答案:

答案 0 :(得分:0)

代码中的

list是Python内置对象list(类型)。

请在那里提供实际的列表对象。