title: django FileNotFoundError when using with open() function
body: <p>Im creating a new thread to ask this question because i have tried every solution i found but non seems to be working for me. I want to output pdf files stored in media sub directory.  @Compadre suggested some links that really helped me understand how the file system works in python but so solutions provided in the threads are not working. i want to output files in the following directory structure:</p>
  
  <pre><code>media/QuestionPapers/filename.pdf
  </code></pre>
  
  <p>view function for outputting the file is:</p>
  
  <pre><code>def Display(request, file_name):
  
  
      File_Name = file_name.replace('_', ' ')
      file_path = os.path.join(settings.MEDIA_ROOT, 'QuestionPapers',File_Name)
  
      with open(file_path,'rb') as pdf:
          response = HttpResponse(pdf.read(), content_type = 'application/pdf')
          response['Content-Disposition'] = 'attachment; filename=some_file.pdf'
      return response
  </code></pre>
  
  <p>when i do</p>
  
  <pre><code>return HttpResponse(os.path.join(settings.MEDIA_ROOT, 'QuestionPapers',File_Name))
  </code></pre>
  
  <p>it returns the absolute path to the file i like to out put but i when use the path in my code as shown above i get the is Errors:</p>
  
  <pre><code>[Errno 2] No such file or directory: 'C:\\Users\\majmaj\\projects\\qbank\\Scripts\\QuestionBank\\media\\QuestionPapers\\filename.pdf'
  </code></pre>
  
  <p>the directory and file does exist because when i do <code>http://127.0.0.1:8000/media/QuestionPapers/myfile.pdf</code>, the file is opened but i don't know why the <code>open()</code> is not working even when the path to the file is correctly</p>
  
  <p>so one should please look into this and tell me what I'm doing wrong, I'm  stuck with this issue and its driving me nuts. this is the fifth day and still no solution </p>