title: MultiValueDictKeyError: 'file_URL' on passing a URL
body: <p>I have a form which contains a file upload but I am not uploading file through that, I store it into firebase storage then pass the URL through ajax request. I found the error - The request is being made before my image is even uploaded to storage and I get url, therefore blank request is passed. Is there a way to fix it ?</p>
  <p>In my views.py I got -:</p>
  <pre><code>if request.method == 'POST':
      title = request.POST['title']
      time = request.POST['time']
      description = request.POST['description']
      file_URL = request.POST['file_URL']
      date = request.POST['date']
  </code></pre>
  <p>The error occurs on <code>file_URL = request.POST['file_URL']</code></p>
  <p>As it says django.utils.datastructures.MultiValueDictKeyError: 'file_URL'</p>
  <p>In my template I have a very simple form -</p>
  <pre><code>&lt;form id=&quot;create-assignment&quot;&gt;
      {% csrf_token %}
      &lt;div class=&quot;title-time-wrapper&quot;&gt;
          &lt;input type=&quot;text&quot; name=&quot;assignment-title&quot; id=&quot;assignment-title-input&quot; required class=&quot;assignment-form-input&quot; placeholder=&quot;Title&quot; autocomplete=&quot;off&quot;&gt;
          &lt;input type=&quot;text&quot; name=&quot;assignment-time&quot; class=&quot;assignment-form-input&quot; id=&quot;assignment-time-input&quot; required placeholder=&quot;Time&quot; autocomplete=&quot;off&quot;&gt;
      &lt;/div&gt;
      &lt;textarea rows=&quot;5&quot; cols=&quot;40&quot; name=&quot;progress&quot; id=&quot;assignment-description-input&quot; required class=&quot;assignment-form-input&quot; placeholder=&quot;Description&quot; autocomplete=&quot;off&quot;&gt;&lt;/textarea&gt;
      &lt;input type=&quot;file&quot; name=&quot;files[]&quot; id=&quot;assignment-file-input&quot;&gt;
      &lt;input type=&quot;submit&quot; class=&quot;submit-btn&quot; value=&quot;Save&quot; id=&quot;assignment-form-submit&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p>And finally for my Javascript -:</p>
  <pre><code> var file, file_URL
   var storage = firebase.storage();
   var storageref = storage.ref('Assignments').child('test');
  
   $(document).on('submit', '#create-assignment', function(e){
          let today = new Date().toISOString().slice(0, 10)
          file = document.getElementById(&quot;assignment-file-input&quot;).files[0];
          var thisref=storageref.child(file.name).put(file);
          thisref.on('state_changed',function(snapshot) {
                  console.log('Done');
              }, function(error) {
                  console.log('Error',error);
              }, function() {
              // Uploaded completed successfully, now we can get the download URL
              thisref.snapshot.ref.getDownloadURL().then(function(downloadURL) {
                  file_URL = downloadURL;
              });
          });
          e.preventDefault();
          $.ajax({
              type: 'POST',
              url: '/teacher/exam/create/',
              data:{
                  title: $('#assignment-title-input').val(),
                  time: $('#assignment-time-input').val(),
                  description: $('#assignment-description-input').val(),
                  file_URL: file_URL,
                  date: today,
                  csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val()
              }
          });
          $('#create-assignment').trigger(&quot;reset&quot;); 
  });
  </code></pre>
  <p>This is an example URL - <a href="https://i.stack.imgur.com/ccbHv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ccbHv.png" alt="enter image description here" /></a></p>
  <p>I found a few solutions but all of them were for django forms asking to change 'enctype' if anyone could help that would be really helpful.</p>