My django web app makes and save docx and I need to make it downloadable.
I use simple render_to_response as below.
return render_to_response(\"
Is it possible, that your path to 'test.docx' contains non-ascii-characters? Did you check all local variables on the django debug page?
What I did to download an xml file was not to create the file on disc but to use a memory file (saves me from dealing with file systems, path, ...):
memory_file = StringIO.StringIO()
memory_file.writelines(out) #out is an XMLSerializer object in m case
response = HttpResponse(memory_file.getvalue(), content_type='application/xml')
response['Content-Disposition'] = 'attachment; filename="my_file.xml"'
response['Content-Length'] = memory_file.tell()
return response
Maybe you can adapt this to your docx-situation.