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

Time:01-29

I have a form on index.html and I want to pass data of all input fields of index.html to demo.html by using a button. Here is my code """

{% 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>

CodePudding user response:

Is the form a post?

You could do something like:

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

Then in your other view for demo.html you could call the session.

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

Then you could just add post_values to your context or whatever you are passing through to your demo.html view.

  •  Tags:  
  • Related