在我的models.py文件中有这样一个类:
class DepartmentCategory(Enum):
"""The various categories of departments"""
committee = 'Committee'
subcommittee = 'Subcommittee'在我的表单的选择字段中使用的。所有的工作都很好,但是当我向Enum类添加一个新值时,例如:
class DepartmentCategory(Enum):
"""The various categories of departments"""
general = 'General'
committee = 'Committee'
subcommittee = 'Subcommittee'保存新值,数据库失败,终端和浏览器都不显示错误。我已经多次迁移(flask db迁移)和升级(flask db升级)我的数据库,但问题没有解决。请帮帮忙。
发布于 2018-11-21 16:58:17
尝试安装enum34。当我在Python3-x上使用enum时,我发现flask_migrate不能检测到变化。然后我看到了这个问题Defining SQLAlchemy enum column with Python enum raises "ValueError: not a valid enum"中的评论
pip安装enum34
注意:继续使用import enum,import enum34是错误的。
发布于 2018-11-21 01:56:35
您需要迁移数据库定义,例如使用https://pypi.org/project/alembic/
https://stackoverflow.com/questions/53396382
复制相似问题