最近看到 [Peewee](https://github.com/coleifer/peewee) 这个超简洁的 Python ORM,试着用了下,定义 User 模型:
```
USER_ROLE = ('user', 'admin')
class User(BaseModel):
username = CharField()
role = CharField(choices=USER_ROLE, default='user')
```
创建表单后插入数据,注意这个 role 并不在我的 [choices](http://peewee.readthedocs.org/en/latest/peewee/models.html#field-initialization-arguments) 里
```
k = User(username='admin', role='chairman')
k.save()
```
发现竟然插入成功了,可是我明明限制了 `choices` 啊,为什么会这样呢?
```
USER_ROLE = ('user', 'admin')
class User(BaseModel):
username = CharField()
role = CharField(choices=USER_ROLE, default='user')
```
创建表单后插入数据,注意这个 role 并不在我的 [choices](http://peewee.readthedocs.org/en/latest/peewee/models.html#field-initialization-arguments) 里
```
k = User(username='admin', role='chairman')
k.save()
```
发现竟然插入成功了,可是我明明限制了 `choices` 啊,为什么会这样呢?