title: Django request.GET does not contain name of submitted form button
body: <p>I'm basically having the same issue addressed in a previous question (<a href="https://stackoverflow.com/questions/2159795/django-request-post-does-not-contain-the-name-of-the-button-that-submitted-the-f">Django request.POST does not contain the name of the button that submitted the form</a>) but the fix described there does not work.</p>
  
  <p>I am using ajax so that, after submission, I stay on the same page. My page has two forms. The first form has three buttons and I correctly pass the "name" of the button in the GET request. My second form has two buttons but I am unable to pass the "name" of either button in the GET request (the "name" of the input field, however, is in the GET request). I don't know why it's not working. Any ideas? </p>
  
  <p>JS SOLUTION: </p>
  
  <pre><code>$(document).ready(function(){
      console.log("hello from email.js");
      $('.email_citations').submit(function(event){
          console.log("submit email");
          var whichButton = $(".form_button[clicked=true]")[0].value
          console.log("WHICH BUTTON: ");
          console.log(whichButton);
          var email_address = $(this).val();
          var data = $(this).serialize();
          data += "&amp;" + whichButton;
          console.log(data);
          $.ajax({
              data: data,
              type: $(this).attr('method'),
              url: $(this).attr('action'),
              success: function(data){
                  console.log("DATA: ");
                  console.log(data);
                  $('.email_sent_message').html(JSON.parse(data).submit_message);
              }
          });
          return false;
      });
      $(".form_button").click(function() {
          $(".form_button").removeAttr("clicked");
          $(this).attr("clicked", "true");
      });
  });
  </code></pre>
  
  <p>html forms:</p>
  
  <pre><code>&lt;!-- This form works! --&gt;
  &lt;form action="export_options" method="get"&gt;
      &lt;button type="submit" name="plain" class="button inline large hover" id="exportButton2"&gt;Download Plain Text&lt;/button&gt;
      &lt;button type="submit" name="ris" class="button inline large hover" id="exportButton1"&gt;Download RIS File&lt;/button&gt;
      &lt;button type="submit" name="bibtex" class="button inline large hover" id="exportButton3"&gt;Download BibTeX File&lt;/button&gt;
    &lt;/form&gt;
  
  &lt;form class="email_citations" id="EmailCitationsForm" action="email_it" method="get"&gt;
      &lt;input class="input-text" type="text" size="75" maxlength="75" style="width: 40%; font-size: 16px; margin-right: 5px; height: 50px" name="email_address" placeholder="email address"&gt;
      &lt;button type="submit" value="selected" name="which_citations" class="form_button button inline large hover" id="exportButton4" &gt;Send My Selected Citations&lt;/button&gt;
      &lt;button type="submit" value="all" name="which_citations" class="form_button button inline large hover" id="exportButton5"&gt;Send All Citations&lt;/button&gt;
  &lt;/form&gt;
  &lt;div class="email_sent_message" style="float: left; color: #9e1d2a; font-size: 20px; font-weight: bold"&gt;{{ submit_message }}&lt;/div&gt;
  </code></pre>
  
  <p>My javascript/ajax in an email.js file:</p>
  
  <pre><code>$(document).ready(function(){
      console.log("hello from email.js");
      $('.email_citations').submit(function(event){
          console.log("submit email");
          var clicked_button = $(".form_button[clicked=true]")[0].name;
          console.log(clicked_button);
          clicked_button.push($(".form_button[clicked=true]")[0].value);
          console.log(clicked_button);
          var email_address = $(this).val();
          var data = $(this).serialize();
          data += "&amp;" + clicked_button;
          console.log(data);
          $.ajax({
              data: $(this).serialize(),
              type: $(this).attr('method'),
              url: $(this).attr('action'),
              success: function(data){
                  $('.email_sent_message').html(JSON.parse(data).submit_message);
              }
          });
          return false;
      });
      $(".form_button").click(function() {
          $(".form_button").removeAttr("clicked");
          $(this).attr("clicked", "true");
      });
  });`
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>def email_it(request):
      context = RequestContext(request)
      if request.method == 'GET':
          getdict = request.GET.dict()
          form = EmailCitationsForm(request.GET)
          if form.is_valid():
              context = request.session.get('All_Citations_Context')
              if ('which_citations') in getdict.keys():
                  if 'all' in getdict.values():
                      text_template = 'email_allCitations.txt'
                      html_template = 'email_allCitations.html'
  
                      text_content = render_to_string(text_template, context, context_instance=RequestContext(request))
                      html_content = render_to_string(html_template, context, context_instance=RequestContext(request))
  
                      msg = EmailMultiAlternatives(subject, text_content, from_email, to)
                      #msg.attach()
                      msg.attach_alternative(html_content, "text/html")
                      msg.send()
                      submit_message = "Thank you. Your citations have been sent via email."
  
                      return http.HttpResponse(json.dumps({'submit_message': submit_message}))
  
                  if 'selected' in getdict.values():
                     text_template = 'email_selectedCitations.txt'
                     html_template = 'email_selectedCitations.html'
  
                      text_content = render_to_string(text_template, context, context_instance=RequestContext(request))
                      html_content = render_to_string(html_template, context, context_instance=RequestContext(request))
  
                      msg = EmailMultiAlternatives(subject, text_content, from_email, to)
  
                      msg.attach_alternative(html_content, "text/html")
                      msg.send()
                      submit_message = "Your citations have been sent via email."
  
                      return http.HttpResponse(json.dumps({'submit_message': submit_message}))
              else:
                  submit_message = "Something went wrong. Sorry, your email did not send."
  
          else:
              submit_message = form.errors['email_address']
      else:
          form = EmailCitationsForm()
          submit_message = ""
      return http.HttpResponse(json.dumps({'submit_message': submit_message}))
  </code></pre>