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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:50:07+00:00 2026-06-10T01:50:07+00:00

I have 2 forms within the same template. One adds Country tags to a

  • 0

I have 2 forms within the same template. One adds Country tags to a current users profile, the other adds Interest tags. Both forms are bring posted to the same url. Both tag fields are filtered through an autocomplete so both fields have their corresponding content. Country input will return a list of Countries, etc.

When I search through the Country Tag field, I’m able to add a country tag. Awesome! However, when trying to add an Interest, the spinner.gif is activated, but within my console the post returns a 404 and therefore doesn’t add the actual interest tag.

Template: The other form is the same, just replace the ids: Country with Interest.

<form id="addCountryTagForm" class="add_tags_form" method="POST" action="/tag/add/"> 
     {% csrf_token %}
     <input id="country-tag-input" class="input-text inline required tag-select" name="tagname" type="hidden" />
     <button class="btn addtag" type="submit" id="addCountryTag">
           <span>Add</span>
      </button> 
</form>

ajax:

$('.add_tags_form').submit(function(e) {
     var $this = $(this);
     var $loader = $('<div class="tag-loader"><img src="/static/images/misc/spinner.gif" /></div>');
     $this.append($loader);

     e.preventDefault();
     var action = $this.attr("action");

     result = $.ajax({
          url: action,
          data: {
               'csrfmiddlewaretoken':$('input[name^="csrfmiddlewaretoken"]').val(),
               'tagname':$('input[name^="tagname"]').val()
           },
           type: "POST",
           success: function(data) {
                $('.tag-section').load('/account/tag-section/');
                $('input[name^="tagname"]').val('');
                $loader.remove();
           },
           error: function(jqXHR, textStatus, errorThrown) {
                $loader.remove();
           }
       });
       return false;
 });

I really don’t know why this isn’t working. Is what I’m trying to accomplish unattainable? Can 2 forms posting to the same url not work within the same template? If anyone could offer inisight, it would be greatly appreciated.

  • 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-10T01:50:09+00:00Added an answer on June 10, 2026 at 1:50 am

    You need to give your button a name attribute. You can post two forms on a single page by checking the name of the button pressed. This can be done like so:

    Technique 1

    ...
    if form.is_valid():
        if "button1" in request.POST:
            # do things for form 1
        elif "button2" in request.POST:
            # do things for form 2
    ...
    

    Technique 2

    Change the name attribute of the hidden field depending on whether you are looking at country or interest.

    You’re also not using jQuery with Django the way that it could best be done. As in, you’re not using the views.py or the forms.py files when submitting the information. Take a look at this answer for using jQuery and Django: How to use JQuery and Django (ajax + HttpResponse)?

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

Sidebar

Related Questions

I have two forms, one to edit room details and the other to edit
I have a MDI application. One of the forms needs to be able to
I have two Const with the same name; One is a global const, and
I have a set of custom PHP forms within a set of Drupal pages
I have two forms, form 1 and form 2; both forms are located in
I have a standard ASP.NET MVC site with forms authentication. Users log in via
function GenKeyForm(FormNum){ document.GenNewKey+FormNum.submit(); } I have multiple forms within a php page. each form
On my page I have multiple forms all the same as this... <form class='bill-upd'>
I have a form within an ASP.NET MVC application and I'm trying to submit
I have a complex input form within a PHP based web application. To structure

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.