0

I'm trying to pass a value to a HTML form through GET request the same way you can do it with WTForms. I want to pre-populate the form fields with some text. When the user edits the values and clicks submit, the new values will be posted and updated in the database. Should I use GET request to do that? Below is a sample of what I'm trying to do

 @app.route("/myroute", methods=["GET", "POST"])
def myroute():
if request.method == 'GET':
    request.form['field1'] = 'some text'
    request.form['fields'] = 'some text'

edit: this is how its done with WTForms

form = SomeForm()

if request.method == 'GET':

    form.field1.data = 'some text'
    form.field2.data = 'some text'

Is this possible?

High Roller
  • 67
  • 2
  • 16

0 Answers0