首页 > 解决方案 > 如何将参数从表单模板传递给请求

问题描述

我想next在提交表单时向请求传递额外的参数(它应该是端点)。我试过了: <form method="post" action="" next="/apply">但它不起作用。稍后收到表格时,我只需要从request.args. 如何正确执行?

标签: httpflaskrequestwtforms

解决方案


您可以使用隐藏的表单域。

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

在您的 Flask 函数中:

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

推荐阅读