如何使用 python django 中的按钮将所有输入字段的数据从一个页面传递到另一个页面

How to pass data of all input fields from one page to another using button in python django

我在 index.html 上有一个表单,我想使用按钮将 index.html 的所有输入字段的数据传递给 demo.html。 这是我的代码 """

{% csrf_token %}
<input type="text" id="xaxis" name="xaxis"><br><br>

<input type="text" id="yaxis" name="yaxis"><br><br>

<button type="submit"> SUBMIT </button>
<button type="submit" name="saveChart" form="axisForm" value="save"> SAVE </button>

表格是post吗?

你可以这样做:

def post(self, request):
   if request.method == 'POST':
       request.session['POSTVALUES'] = request.POST.copy()

然后在 demo.html 的另一个视图中,您可以调用会话。

def get(self, request):
   post_values = request.session.get('POSTVALUES')  

然后您可以将 post_values 添加到您的上下文或您传递给 demo.html 视图的任何内容。