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

  • Home
  • SEARCH
  • 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 7938719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:53:13+00:00 2026-06-03T22:53:13+00:00

I have a Django project that, on one page, has multiple forms (in different

  • 0

I have a Django project that, on one page, has multiple forms (in different tags) that can be submitted to have different effects. In all cases I want the user to be redirected back to the same page, so I use in my view the pattern of submitting the form and then redirecting to the original page. In at least one case, the only difference between two of the forms is the value of the submit button.

In my view I have the code (which is the first time my view function accesses the request.POST):

if request.POST['submit']=='Add':
    #code to deal with the "Add" form

and in the template, the first form has a submit button like

<input type="submit" value="Add">

I thought this would work, but when I submit that form, I get an error at the line in view from above:

Key ‘submit’ not found in <QueryDict: {u'clientyear': [u'2012'], u'csrfmiddlewaretoken': [u'be1f2f051f09f6ab0375fdf76cf6a4d7'], u'ben': [u'123405']}>

Obviously, this does not have a 'submit' key or any key with the value corresponding to the submit button I clicked. So, since this does not work, how can access the value of the submit button or tell which of the forms has been submitted?

  • 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-06-03T22:53:13+00:00Added an answer on June 3, 2026 at 10:53 pm

    Submit is an HTML Form structure… You must use name attribute of form objects as follows… In your template:

    <form>
    ...
    <input type="submit" name="list" value="List Objects" />
    </form>
    <form>
    ...
    <input type="submit" name="do-something-else" value="Do Something Else" />
    </form>
    

    In your view:

    if 'list' in request.POST:
        # do some listing...
    elif 'do-something-else' in request.POST:
        # do something else
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django project which has two apps (one created as debug test).
I've got a Django project that has multiple settings files (www site, mobile site,
I have a Django project, that has a Address model. This is used in
I have an existing Django project that has several models using concrete inheritance of
I have a django project which has two apps, one is AppA and AppB
I have a django project that I have been working on as a solo
I have a django project that runs on a Linux server, and I've been
I have a project that I am working on in django. There are a
I need to have an at-home project now that I'm working on Python/Django at
I have a Django project in which multiple processes are accessing the backend mysql

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.