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 667279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:54:39+00:00 2026-05-13T23:54:39+00:00

I have 3 forms at the same page and each has a different form

  • 0

I have 3 forms at the same page and each has a different form submit. Such as:

<h1>Address</h1>
<form method="post" id="adress_form" action=/profile/update/>
{{ form_address.as_p }}

<p><button type="submit">Save</button></p>
</form>

<h1>Email Change</h1>
<form method="post" id="email_form" action=/profile/update/>
{{ form_email.as_p }}

<p><button type="submit">Save</button> </p>
</form>

<h1>Password Change</h1>
<form method="post" id="password_form" action=/profile/update/>
{{ form_password.as_p }}

<p><button type="submit">Save</button></p>
</form>

For the sake of simplicity, I didn’t include the ajax post scripts, but each submit will be queried via ajax.

Now I want to do processing all at the same page, /profile/update/
For this I have to check which form is posted. If posted and valid give some response, if not give another response.

@login_required
def profile_update_view(request):
    if request.method == 'POST' and request.is_ajax()::
        user = request.user
        form_adress = AdressForm(request.POST)
        form_email = EmailForm(request.POST)
        form_password = PasswordChangeForm(request.POST)

        if <CHECK IF THE SUBMIT IS AN ADDRESS FORM>
            if form_adress.is_valid():
                #update and return a json response object with "adress updated successfully." for ajax
            else:
                answer = {'answer': "Couldn't update. Your form is not valid"}  
                return HttpResponse(simplejson.dumps(answer), mimetype="application/json")

        if <CHECK IF THE SUBMIT IS AN EMAIL FORM>
            if form_email.is_valid():
                #update and return a json response object with "email updated successfully." for ajax
            else:
                answer = {'answer': "Couldn't update. Your form is not valid"}  
                return HttpResponse(simplejson.dumps(answer), mimetype="application/json")

        if <CHECK IF THE SUBMIT IS AN PASSWORD FORM>
            if form_password.is_valid():
                #update and return a json response object with "password changed successfully." for ajax
            else:
                answer = {'answer': "Couldn't update. Your form is not valid"}  
                return HttpResponse(simplejson.dumps(answer), mimetype="application/json")
    else:
        return HttpResponse(u"ONLY AJAX QUERIES PLEASE", mimetype="text/plain", status=403)

I somehow need to find out what form is posted.
How can I do this ?

  • 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-13T23:54:39+00:00Added an answer on May 13, 2026 at 11:54 pm

    Couldn’t you just put a hidden input in each form w/ an identifier, and then just check for that in your view?

    <h1>Address</h1>
    <form method="post" id="adress_form" action=/profile/update/>
    <input type="hidden" name="_address" />
    {{ form_address.as_p }}
    
    <p><button type="submit">Save</button></p>
    </form>
    

    and then in the view:

    if '_address' in request.POST:
        if form_adress.is_valid():
            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application with multiple forms, each form has the same icon, so
I have an html form (each form has different page, according to date), with
function GenKeyForm(FormNum){ document.GenNewKey+FormNum.submit(); } I have multiple forms within a php page. each form
I have a couple of forms on one page without a form name. Each
I have a page which dynamically creates multiple forms, each form had a unique
I have multiple ajax forms on page that cointain same elemets, I have jquery
I have a form that auto submits and updates the same page. I have
I have WPF Form which has many buttons with the same code. Appearance of
On a HTML page I have three sections with 3 tables. Each table has
I have a MVC3 page that is split into tabs. Each tab has a

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.