title: Django executes the view functions many times when client has submitted a form just only once
body: <p>I need to upload user's image to server for django(1.8) to process it.
  I'm sure the client only submits the form only once. Howerver, the backend executed the related view function many times and return 504 when I submitted a little large image(about 2M).</p>
  
  <p>Here is my html:
      </p>
  
  <pre><code> &lt;form action="/test/" method="POST" id="upload_form" enctype="multipart/form-data"&gt;
        {% csrf_token %}
        &lt;a href="javascript:void(0);" class="addPic"&gt;
        &lt;input id="choose_btn" class="btn" name="user_image"  type="file"&gt;&lt;/a&gt;
   &lt;/form&gt;
   &lt;button type="button" id="upload_btn" class="btn btn-danger " data-loading-text="uploading..." autocomplete="off"&gt; Upload!&lt;/button&gt;
  </code></pre>
  
  <p>Here is my js(insure there is only one submit , inspired from <a href="https://stackoverflow.com/a/4473801/1902843">https://stackoverflow.com/a/4473801/1902843</a>):
  </p>
  
  <pre><code>$('#upload_btn').click( function () {
          var $btn = $(this).button('loading');
          $('#upload_form').submit(function(e){
              console.log("start submit");
              var $form = $(this);
              if ($form.data('submitted') === true) {
                  // Previously submitted - don't submit again
                  console.log("has submitted!");
                  e.preventDefault();
              } else {
                  console.log("first submitted");
                  // Mark it so that the next submit can be ignored
                  $form.data('submitted', true);
              }
          });
          $('#upload_form').submit();
      });
  </code></pre>
  
  <p>and my back-end view function is:</p>
  
  <p><strong>model</strong>
  </p>
  
  <pre><code>class UserImage(models.Model):
      image = models.ImageField(upload_to='./user_image/%Y%m/%d', storage=ImageStorage(), blank=False)
      detect_result = models.TextField(max_length=1000, blank=True)
  </code></pre>
  
  <p><strong>view</strong>
  </p>
  
  <pre><code>@csrf_exempt
  def test(request):
      # if use form's is_valid() function, it always return false. 
      # very weird, thus i annotate it
      # if request.method == 'POST':
      #     form = UploadFileForm(request.POST, request.FILES)
      #     if form.is_valid():
      user_image = request.FILES['user_image']
      im = UserImage(image=user_image)
      im.save() #after looking for log, it saved many times depending on image size?
      img_path = settings.MEDIA_URL + str(im.image)
      ...
      processing image
      ...
  
      return render_to_response('open.html', result_data)
  </code></pre>