简体   繁体   中英

WTForms / SQLAlchemy field validation

Is there a quick way to use my SQLAlchemy model to do length validation / instantiate a field for a CRUD form I'm using to interact with the database? I feel like I'm repeating the lengths alot like so...

class MyModel(db.Model):
    ...
    SomeField = db.Column(db.String(30))

with a matching form:

class MyForm(FlaskForm):
    MyFormField = StringField('Some Field', validators=[Length(30)])

没关系,我发现了WTForms-Alchemy https://wtforms-alchemy.readthedocs.io/en/latest/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM