I want my view to respond with a file for downloading, so that the browser pops up the download/file save dialog. I am using the 'Content-Disposition' header to specify the name of the file. When I use the django development server, it works perfectly in Firefox and IE6 (latest versions). When I switch to Apache with mod_python, it continues to work with Firefox, but IE6 apparently ignores the 'Content-Disposition' header and tries to save the file as the GET parameters part of the URL, including the question mark. (For example, if the URL is 'http://192.168.1.109/report?id=12345' then IE will offer to save the file as '?id=12345', while Firefox will use the filename specified in Content-Disposition header. )
Regarding mimetype, I have some alternatives that may work with development server or Firefox, but not with Apache and IE. Regarding the filename format in the Content-Disposition value, Firefox requires quotation marks around the filename if it has spaces in it, but on the development server at least IE can handle them with no spaces. So, can anyone suggest why IE would respect Content-Disposition on development server but not on Apache ? I have the default Apache configuration on Ubuntu 6.06 server, with a modified httpd.conf as described in the django mod_python deployment document. Hmm, one last point to mention: the contents of the report is not a regular Excel file - did you know that you can save an HTML file that has a table in it with a .xls extension and Excel will treat it just like a regular Excel file? (If you modify and save it in Excel it will be converted to a regular Excel file.) So I make the report using an HTML table, but save it as a .xls file and the web service consumer thinks they're getting an Excel file, and everyone is happy. I mention this because I realize IE might be inspecting the contents of the file and deciding it is not really an Excel file. But this would be contrary to the description I read of its behavior, which is that IE respects the Content-Disposition header; and anyway, why would it happen on Apache but not on the Django development server? Enough, here is the view code: from django.http import HttpResponse from mymodule import prepare_report def get_report(request): try: id = request.GET["id"] int(id) except KeyError, ValueError: raise Http404 report_filename, report = prepare_report(id) #response = HttpResponse(mimetype='application/octet-stream') #response = HttpResponse(mimetype='application/msexcel') response = HttpResponse(mimetype='application/vnd.ms-excel') #response['Content-Disposition'] = 'attachment; filename=%s' % report_filename response['Content-Disposition'] = 'attachment; filename="%s"' % report_filename response.write(report) return response --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---