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.