我的用户应该能够为我的表创建新行,但是当我在Flask-AppBuilder中使用加号按钮时,主键没有显示,并且生成的SQL INSERT语句缺少主键,这显然是失败的。
如何让Flask-AppBuilder显示新行的主键?
示例
models.py
class Catalogue(Model):
id = Column(String(200), primary_key=True)
label = Column(String(200), nullable=False)
type = Column(Enum("UserGroup","ApplicationSystem","Feature","EnterpriseFunction","OrganizationalUnit"), nullable=False)views.py
class CatalogueView(ModelView):
datamodel = SQLAInterface(Catalogue)
label_columns = {'label':'Name', }
list_columns = ['id', 'label', 'type']
related_views = [ClassifiedView]现在,当我运行应用程序时,我可以在视图http://127.0.0.1:5000/catalogueview/list/中看到"id“字段。
但是,当我在http://127.0.0.1:5000/catalogueview/show/myexamplecatalogue进入细节视图时,主键字段"id“被隐藏,使用http://127.0.0.1:5000/catalogueview/add创建新条目时也会发生同样的情况,然后失败,如上所述。
如何阻止Flask-AppBuilder隐藏我的主键并成功创建新条目?
发布于 2020-09-02 22:06:39
正如@IljaEverilä所建议的,这可以使用"edit_columns“属性添加:
class CatalogueView(ModelView):
datamodel = SQLAInterface(Catalogue)
label_columns = {'label':'Name', }
list_columns = ['id', 'label', 'type']
related_views = [ClassifiedView]
edit_columns = ['id', 'label', 'type']https://stackoverflow.com/questions/63706300
复制相似问题