title: django MultiValueDictKeyError error at request.FILES['file']
body: <p>I am new to python/django and unable to figure out the issue. The requirement is to upload a csv file to load the data into the database.</p>
  
  <p>I have a custom model for users where the data needs to be loaded. Error seems to be occurring at 
  csv_file = request.FILES['file']</p>
  
  <p>Error- </p>
  
  <pre><code>MultiValueDictKeyError at /upload-csv/ 'file'
  Request Method: POST
  Request URL:    http://127.0.0.1:8000/upload-csv/
  Django Version: 2.2.2
  Exception Type: MultiValueDictKeyError
  Exception Value:    
  'file'
  Exception Location: D:\djreact\backend\env\lib\site-    packages\django\utils\datastructures.py in __getitem__, line 80
  Python Executable:  D:\djreact\backend\env\Scripts\python.exe
  Python Version: 3.7.2
  Python Path:    
  ['D:\\djreact\\backend\\src',
   'D:\\djreact\\backend\\env\\Scripts\\python37.zip',
   'D:\\djreact\\backend\\env\\DLLs',
   'D:\\djreact\\backend\\env\\lib',
   'D:\\djreact\\backend\\env\\Scripts',
   'd:\\python\\python37\\Lib',
   'd:\\python\\python37\\DLLs',
   'D:\\djreact\\backend\\env',
   'D:\\djreact\\backend\\env\\lib\\site-packages']
  Server time:    Tue, 2 Jul 2019 12:49:52 +0000
  </code></pre>
  
  <p>View.py -</p>
  
  <pre><code>def user_upload(request):
  template="user_upload.html"
  prompt = {
      'order': 'order of csv should be first_name, last_name, email'
  }
  if request.method == "GET":
      return render(request, template, prompt)
  
  csv_file = request.FILES['file']
  
  data_set = csv_file.read().decode('UTF-8')
  io_string = io.StringIO(data_set)
  next(io_string)
  for column in csv.reader(io_string, delimiter=',', quotechar="|"):
      _, created =  User.Objects.update_or_create(
      first_name = column[0],
      last_name = column[1],
      email = column[2]
      )
  return render(request, template)
  </code></pre>
  
  <p>template - user_upload.html</p>
  
  <pre><code>{% if messages %} {% for message in messages %}
  &lt;div&gt;
      &lt;strong&gt;{{message|safe}}&lt;/strong&gt;
  &lt;/div&gt;
  {% endfor %} {% else %} {{order}}
  &lt;form method="post" encrypt="multipart/form-data"&gt;
  {% csrf_token %}
      &lt;label&gt; Upload a file &lt;/label&gt;
      &lt;input type="file" name='file'&gt;
      &lt;/br&gt;
          &lt;button type="submit"&gt; Upload&lt;/button&gt;
  &lt;/form&gt;
  {% endif %}
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>class DepUser(models.Model):
      first_name = models.CharField(max_length=30)
      last_name = models.CharField(max_length=30)    
      email = models.EmailField(max_length=100, unique=True)
      emailVerifCode = models.CharField(null = True,blank=True, max_length=30)
  </code></pre>