Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3874900
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:12:17+00:00 2026-05-19T22:12:17+00:00

I’m new to Django and I have a page with several forms and submit

  • 0

I’m new to Django and I have a page with several forms and submit buttons. How can I store the data on the fields of the other forms if one is submitted? Normally when I submit one, it redirects to the same page but if something was typed on the fields is lost.
Thanks.

This is the Html

<head>
    <title>Hello</title>
    <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}/static/tabs.css"  />
</head>
<body>
     <h1>Informacion</h1>
     <ol id="toc">
     <li><a href="#page-1"><span>Page 1</span></a></li>
     <li><a href="#page-2"><span>Page 2</span></a></li>
     <li><a href="#page-3"><span>Page 3</span></a></li>
 <li><a href="#page-4"><span>Page 4</span></a></li>
     </ol>
     <div class="content" id="page-1">
        <h2>Page 1</h2>
        <p>Text...</p>
    <form action="." method="POST">{% csrf_token %}
        <table>
    {{ form1.as_table }}
        </table>
        <p><input type="submit" value="Submit"></p>
        </form>
      </div>
      <div class="content" id="page-2">
         <h2>Page 2</h2>
         <p>Text...</p>
         <form action="." method="POST">{% csrf_token %}
     <table>
     </table>
     <p><input type="submit" value="Submit"></p>
         </form>
      </div>
      <div class="content" id="page-3">
         <h2>Page 3</h2>
         <p>Text...</p>
     <form action="." method="POST">{% csrf_token %}
     <table>
     {{ form2.as_table}}
     </table>
     <p><input type="submit" value="Submit"></p>
         </form>
     </div>
     <div class="content" id="page-4">
     <h2>Busqueda</h2>
     <form action="." method="POST">{% csrf_token %}
     <table>
     {{ form2.as_table}}
     </table>
     <p><input type="submit" value="S"></p>

     </div> 
     <script src="{{ MEDIA_URL}}/static/activatables.js" type="text/javascript"></script>
     <script type="text/javascript">
     activatables('page', ['page-1', 'page-2', 'page-3','page-4']);
     </script>

     </body>

Well, there are some tabs made in java script for each different form, so what I want to do is that when you submitt data for one form, the other data in the fields of the rest of the forms should be kept, so the user shouldnt type it again or lose it. Thanks in advance.

in the view…

if request.method == 'GET':
    form1 = HcGinecoForm()
    form2 = HolaForm()
else:
    form1 = HcGinecoForm(request.POST)
    form2 = HolaForm(request.POST)
    if form1.is_valid and form2.is_valid():
        form1.save()
        form2.save()
return render_to_response('polls/hola.html',{
                           'form2':form2,
                           'form1':form1
                           })

It’s working so far… thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:12:18+00:00Added an answer on May 19, 2026 at 10:12 pm

    In order to persist the values from multiple forms from one POST, you’ll need to have all of the fields in one form (without using JavaScript).

    In your view action, you would need to validate each form, and then call it’s save method.

    def my_page(request):
        if request.method == 'GET':
            form1 = Form1()
            form2 = Form2()
            form3 = Form3()
        else:
            form1 = Form1(request.POST)
            form2 = Form2(request.POST)
            form3 = Form3(request.POST)
    
            if form1.is_valid() and form2.is_valid() and form3.is_valid():
              form1.save()
              form2.save()
              form3.save()
        return render_to_response('my_page.html',
              {'form1' : form1, 'form2' : form2, 'form3' : form3})
    

    When posting to this action, the values input into any of these forms will be preserved after the post. If you want the values to not be preserved, you’ll need to create new instances of the forms that aren’t populated from the request.POST collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.