根据模型视图的文档,我在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))
表";软件复制品";存在于数据库中,并且有多个条目。我假设它自动地将类";软件产品;到桌子上";软件复制品";,因为我看不到任何手动链接的选项。如果有,请告诉我。在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.创建了用户表,我可以登录。
Flask AppBuilder将SoftwareProduct等camelcase名称映射到software_product等下划线表名称中,但表名称为softwarereproduct。要修复映射,请将类名从"更改为";软件产品;至";软件产品";。