我的
Document
模型具有
text_location
列,查询后需要读取的文件路径。我正在使用
paginate
查询时。
通过此代码创建的:
class Document(db.Model):
id = db.Column(db.Integer, primary_key=True)
text_location = db.Column(db.String)
page_views = Document.query.paginate(page, 1, False)
我可以显示
{{ page_views }}
在模板中正确显示。但是,如果我尝试打开
text\u位置
,我明白了
"Pagination" object has no attribute "text_location"
。
with open(page_views.text_location) as f:
document_text = f.read()
如何阅读
text\u位置
对于
Documents
我问过?