Skip to content
Browse files

Adding to the example app showing use of custom validators on form

  • Loading branch information...
1 parent 5359f5f commit a26b3c5ce104f74de59469d2054ddbffe9023c64 @coleifer committed May 20, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 example/
7 example/
@@ -19,6 +19,7 @@
from flask import Flask, redirect, render_template, request, g, abort, url_for, flash
from peewee import *
+from wtforms.validators import Length
from wtfpeewee.fields import ModelHiddenField
from wtfpeewee.orm import model_form, ModelConverter
@@ -77,7 +78,11 @@ class HiddenForeignKeyConverter(ModelConverter):
def handle_foreign_key(self, model, field, **kwargs):
return, ModelHiddenField(, **kwargs)
-PostForm = model_form(Post)
+PostForm = model_form(Post, field_args={
+ 'title': dict(validators=[Length(min=3, max=200)]), # title must be at least 3 chars long
+ 'content': dict(description='this is the body of the post'), # a little help text
CommentForm = model_form(Comment, exclude=('pub_date',), converter=HiddenForeignKeyConverter())

0 comments on commit a26b3c5

Please sign in to comment.
Something went wrong with that request. Please try again.