Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can wtforms be used to validate GET parameters?

I have a set of GET parameters that I want to validate. Can I use WTFORMS for that purpose? All examples I find are of POST requests.

like image 418
Private Avatar asked Dec 19 '22 13:12

Private


1 Answers

Pass request.args instead of request.form when instantiating the form. They both use the same data structure, but args contains query args instead of form data.

form = MyForm(request.args)

Flask-WTF will pass form if nothing is specified, but you can still override it by passing args.

like image 128
davidism Avatar answered Dec 31 '22 14:12

davidism