I looked at various issues similar to mine, but I could not find anything that could fix my problem.
In my code, I want to serve the newly created excel file located in my application directory, in the folder with the file names
excelFile = ExcelCreator.ExcelCreator("test") excelFile.create() response = HttpResponse(content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename="test.xls"' return response
Therefore, when I click on the button that launches this piece of code, it sends the user an empty file. Looking at my code, I can understand this behavior, because I do not point to this file in my answer ...
I saw some people use the file wrapper (which I don't quite understand). So I liked it:
response = HttpResponse(FileWrapper(excelFile.file),content_type='application/vnd.ms-excel')
But then I get an error message from the server: a server error has occurred. Contact your administrator.
Thank you for helping me in the Django quest, I am getting better with all your precious tips!
Speccy
source share