I would like a form validation library that
1.separate html generation from form validation;
2.validation errors can be easily serialized, eg. dumped as a json object
What form validation library would you choose in a python web project?
I would like a form validation library that
1.separate html generation from form validation;
2.validation errors can be easily serialized, eg. dumped as a json object
What form validation library would you choose in a python web project?
It depends wheather, and then, what type of framework you use.
For your task, I would recommend you to use the web2py-Framework, which is easy to use and still "mighty". It has form-validation by default (the web2py-book is free), that does exactly what you want: It sepereates the html generation from the validation and does this automatically, but you can, if you wish, customize it.
An example:
def display_form():
form=FORM('Your name:',
INPUT(_name='name', requires=IS_NOT_EMPTY()),
INPUT(_type='submit'))
if form.accepts(request.vars, session):
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill the form'
return dict(form=form)
It's also possible to serialize errors, but for those questions it's the best to ask them on the web2py-group. They're very nice and will help you very fast.
Hope it helps! Best regards..
it depends on what underlying framework you use.
for django , built in form framework is best,
while kay uses extended version of zine's form system
and tipfy uses WTForms.
django's built in system is best so far .
what framework do you use under the hood ?