首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Flask-AppBuilder时“找不到任何记录”

使用Flask-AppBuilder时“找不到任何记录”
EN

Stack Overflow用户
提问于 2020-08-20 18:31:33
回答 1查看 61关注 0票数 1

遵循有关Model Views的文档,我用models.py构建了以下模型:

代码语言:javascript
复制
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中有一个它的视图

代码语言:javascript
复制
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.创建了用户表,我可以登录。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-20 19:46:06

software_product -AppBuilder将驼峰名称映射为下划线的表名称,但表名是softwareproduct。要修复映射,请将类名从"Softwareproduct“更改为"SoftwareProduct”。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63503171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档