遵循有关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.显示现有的记录?
我使用Python3.8.5和Flask 1.1.2以及PostgreSQL数据库。
我知道数据库连接是有效的,因为F.A.B.创建了用户表,我可以登录。
发布于 2020-08-20 19:46:06
software_product -AppBuilder将驼峰名称映射为下划线的表名称,但表名是softwareproduct。要修复映射,请将类名从"Softwareproduct“更改为"SoftwareProduct”。
https://stackoverflow.com/questions/63503171
复制相似问题