Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

choices just like django or mongoengine #93

ddorian opened this Issue Jun 7, 2012 · 4 comments


None yet
3 participants

ddorian commented Jun 7, 2012

Add choices to fields like django and mongoengine.


coleifer commented Jun 8, 2012

i'm on the fence about this, should they be implemented as a check constraint or solely in python? if you assign something that is an invalid choice, should it error out? if so, what type of error?


coleifer commented Jun 8, 2012

i checked django, it seems you can assign invalid values to a field that specifies choices. you can also save these invalid choices. probably just for modelform validation. so, options:

  • db-level check constraint -- bad because if you want to change your choices that means schema change
  • python-level on save
  • python-level on assignment
  • none at all, just for metadata and other libraries (flask-peewee, wtf-peewee)

I'm leaning towards none at all, same as django.

cbess commented Jun 8, 2012

Maybe it should output a warning in DEBUG mode


coleifer commented Jun 8, 2012

I've added this in commit 2d076f0

I've also added integration in the wtf-peewee bindings (wtforms form library integration)

I've also added a small example to the flask-peewee app:

Finally, there's no debug mode per se with peewee, so there's no warning

@coleifer coleifer closed this Jun 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment