title: Downloading a csv file in django
body: <p>I am trying to download a CSV file using HttpResponse to make sure that the browser treats it as an attachment. I follow the instructions provided <a href="http://docs.djangoproject.com/en/dev/ref/request-response/#telling-the-browser-to-treat-the-response-as-a-file-attachment" rel="noreferrer">here</a> but my browser does not prompt a "Save As" dialog. I cannot figure out what is wrong with my function. All help is appreciated.</p>
  
  <pre>
    dev savefile(request):
          try:
              myfile = request.GET['filename']
              filepath = settings.MEDIA_ROOT + 'results/'
              destpath = os.path.join(filepath, myfile)
              response = HttpResponse(FileWrapper(file(destpath)), mimetype='text/csv' ) 
              response['Content-Disposition'] = 'attachment; filename="%s"' %(myfile)
              return response
          except Exception, err:
              errmsg = "%s"%(err)
              return HttpResponse(errmsg)
  </pre>
  
  <p>Happy Pat's day!</p>