0

I have the following setup:

The rendering page:

@app.route('/one', methods=['GET'])
def one():
    form = AnyForm()
    return render_template(
        'form.html', form=form
    )

The template (stripped to the basic):

{{ wtf.quick_form(form, action=url_for('two')) }}

The route/function including the logic

@app.route('/two', methods=['POST'])
def two(form):
    print('FORMDATA: ' + form)
    return redirect(url_for('one'))

The error is:

TypeError: two() missing 1 required positional argument: 'form'

How do I handle this?

Dakkar
  • 5,682
  • 5
  • 22
  • 28

1 Answers1

1

You have to define the form on functuin two and populate it from post request that the function recieves, this way you dont need to get any argument

try this:

@app.route('/two', methods=['POST'])
def two():
    form = AnyForm(request.form)
    print('FORMDATA: ' + form)
    return redirect(url_for('one'))

and the way you tried, you have to give your url_for function a form argument like this

{{ wtf.quick_form(form, action=url_for('two', form=form)) }}

Im not sure if it works

DarkSuniuM
  • 2,523
  • 2
  • 26
  • 43