Search code examples
httpflaskrequestwtforms

How to pass the arguments to the request from the form template


I'd like to pass additional argument next (it should be endpoint) to the request when submitting the form. I've tried: <form method="post" action="" next="/apply"> but it doesn't work. Later when receiving the form I just need to read it from request.args. How to do it correctly?


Solution

  • You can use a hidden form field.

      <form method="post" action="">
        <input type="hidden" name="next" value="/apply">
        <!-- the rest of your form code -->
    

    In your Flask function:

        next = request.form.get('next')