python - 如何在 peewee 2 中创建带有枚举的表模型?

标签 python peewee

我正在尝试创建一个模型来描述 peewee 中带有枚举字段的表.

我看到在 2.0 版本之前,EnumField 已从 peewee.py 文件中删除,而且我在当前文档中找不到任何概述如何实现它的内容。有谁知道我是否可以只使用 CharField?

最佳答案

这是一个适用于 PostgreSQL 的可行解决方案:

https://gist.github.com/b1naryth1ef/607e92dc8c1748a06b5d

关于python - 如何在 peewee 2 中创建带有枚举的表模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13923382/

相关文章:

python - SQLite 的 peewee 中的 Order_By 自定义日期

python - Peewee - 在运行时确定有关模型的元数据

python - Wagtail 查询 - 日期范围、类型选择和限制

Python 测试 : Simulate ImportError

python - 等待在挤压中设置对象属性

python - Peewee 按天计算条目数

python - 从 python 中隐藏取消隐藏工作表

python - 插入不使用 Python 的数据库表

python - Peewee:减少条件语句在一定长度后中断的位置

peewee - chalice 和皮维,错误通过调用不同的 View