librelist archives

« back to archive

Declarative enum (SQLAlchemy) with WTForms

Declarative enum (SQLAlchemy) with WTForms

From:
Dries De Smet
Date:
2014-12-18 @ 17:26
Hello,

Has anyone used the Declarative enum  (
http://techspot.zzzeek.org/2011/01/14/the-enum-recipe/) together with
WTForms?

 I can get the select field to show the values, but whenever I'm trying to
submit (flask-admin), it says it's not a valid choice. I've tried setting
the value to just the key of the enum, which fails because the bind
parameters of the column tries to find a value.value, and also setting it
MyEnum.from_string(key), but that fails as well.

Quite a specific question, but not sure where to ask it..!

Kind regards,

Dries