Hello AT, Thanks for your suggestion but I cannot do it this way because I can only developpe with the built-in server. So that's why I was trying to to send it through response. Do you have a suggestion for that?
Thanks again, VB 2011/11/10 Andre Terra <andrete...@gmail.com> > You should serve your files directly through the server (preferably not > the built-in django development server), instead of writing a django view. > > Use nginx[1], apache[2] or any other server, then place the excel file in > a directory outside of your django app, and write an alias to that location. > > > Cheers, > AT > > [1] http://wiki.nginx.org/HttpCoreModule#location > [2] http://httpd.apache.org/docs/2.2/mod/core.html#location > > > On Thu, Nov 10, 2011 at 4:55 PM, Virginia <virginia.bel...@gmail.com>wrote: > >> Good day everyone, >> >> I'm trying to allow a user to dowload to his machine an excel file >> from the server. This is my code: >> >> wrapper = FileWrapper(open(path_to_file)) >> content_type = mimetypes.guess_type(path_to_file)[0] >> response = HttpResponse(wrapper,content_type=content_type) >> response['Content-Length'] = >> os.path.getsize(path_to_file) >> response['Content-Disposition'] = "attachment; filename= >> %s"%file_name >> response['X-Sendfile'] = smart_str(path_to_file) >> return response >> >> But when I do that I get the "save as" window poping out. I choose >> where to put my file. Once this is done and the file downloaded, when >> I try to open it, it's like I get all the excel file in on sheet names >> as the file. So how can I download the file? What am I doing wrong? >> >> Thanks, >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.