【发布时间】:2020-12-09 16:16:20
【问题描述】:
按照Model Views 上的文档,我在models.py 中构建了以下模型:
class SoftwareProduct(Model):
suffix = Column(String(200), primary_key=True)
label = Column(String(200), nullable=False)
comment = Column(String)
coderepository = Column(String(200))
“softwareproduct”表存在于数据库中,并且有多个条目。
我假设它自动将类“SoftwareProduct”链接到表“softwareproduct”,因为我没有看到任何手动链接它的选项。如果有并且缺少,请告诉我。
在views.py有一个视图:
class SoftwareProductView(ModelView):
datamodel = SQLAInterface(SoftwareProduct)
label_columns = {'label':'Name', 'comment':'Comment'}
[...]
db.create_all()
appbuilder.add_view(
SoftwareProductView,
"Software Product",
icon = "fa-folder-open-o",
category = "Software Product",
category_icon = "fa-envelope"
)
但是,当我启动应用程序时,我收到“未找到记录”。我怎样才能获得 F.A.B.显示现有记录?
我使用 Python 3.8.5 和 Flask 1.1.2 和 PostgreSQL 数据库。
我知道数据库连接有效,因为 F.A.B.创建用户表,我可以登录。
【问题讨论】:
标签: python flask flask-appbuilder