title: python-django file upload 'key error'
body: <p>I am using python 3.2 &amp; django 1.6. I want to upload to upload a 'csv' file and read data inorder to insert it into database(postgresql).  Here is my code<br>
  Template  </p>
  
  <pre><code>&lt;form id = "ListForm" name = "ListForm" action = "" method = 'POST' enctype="multipart/form-data"&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;PM List&lt;/td&gt;
  &lt;td&gt;&lt;input type="file" name="file_pm" id="file_pm" &gt;&lt;/td&gt;
  &lt;/tr&gt;   
  &lt;tr&gt;&lt;td&gt;&lt;input type="submit" value="Upload" name="pmUpload" id="pmUpload" class="button"&gt;&lt;/td&gt;&lt;/tr&gt;       
  &lt;/table&gt;
  &lt;/form&gt;  
  </code></pre>
  
  <p>Python code is:  </p>
  
  <pre><code>import cgi
  def pmUpload(request):
      form = cgi.FieldStorage()
      fileitem = form["file_pm"]  
  </code></pre>
  
  <p>I got 'KeyError' in the lastline of the above python code.I was trying to read data one by one.  </p>
  
  <p>And the full traceback error is  </p>
  
  <pre><code>Environment:
  
  
  Request Method: POST
  Request URL: http://MYURL/cc/pmList/
  
  Django Version: 1.6.5
  Python Version: 3.2.3
  Installed Applications:
  ('django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'ccApp')
  Installed Middleware:
  ('django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware')
  
  
  Traceback:
  File "/home/env/ccENV/lib/python3.2/site-packages/django/core/handlers/base.py" in get_response
    112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/env/ccENV/lib/python3.2/site-packages/django/views/decorators/csrf.py" in wrapped_view
    57.         return view_func(*args, **kwargs)
  File "/home/env/ccENV/lib/python3.2/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
    22.                 return view_func(request, *args, **kwargs)
  File "/home/env/cccENV/ccc/ccApp/pmList.py" in pmUpload
    19.       fileitem = form["file_pm"]
  File "/usr/lib/python3.2/cgi.py" in __getitem__
    575.             raise KeyError(key)
  
  Exception Type: KeyError at /cc/pmList/
  Exception Value: 'file_pm'  
  </code></pre>
  
  <p>How to read data in python 3.2 from the uploaded file(data.csv)</p>