Question

I am new to python and flask and trying to understand "wtforms" but so far didn't find any tutorials that actually explains the complete functionality. Like in some places data is set in the "GET" request like

form.country = DBModel.country

some use it like

form.country.data = DBModel.country

other use it like

form.country.query = DBModel.country

The other thing I don't understand is "wtforms" functionality in "POST" request.

Where exactly data is extracted from the request?

I cannot see any data extraction from request in any example. They simply define the instance of "wtform" and starts adding the data to DB.

Was it helpful?

Solution

If You are new in Python and Flask read this blog :) It contains series of articles how to start and develop the flask project. It can be very useful.

About problems with wtforms try to find something useful in flask snippets.

In wtforms.Form you have properties data - it is a dict containing the data for each field. If You want to fill form with data from model there is populate_obj() method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top