Score:1

Response with and in memory file with Django and nginx

uz flag

I have a piece of code that works fine on my local setup (Django embeded dev server running on Windows) but not on server (ubuntu + gunicorn + nginx)

I build an Excel file et send it from memory like so

output = io.BytesIO()

workbook = Workbook(output, {"in_memory": True})

worksheet_user_list = workbook.add_worksheet()

# Fill file...

workbook.close()

output.seek(0)

response = HttpResponse(
    output.read(),
    content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)
response[
    "Content-Disposition"
] = f"attachment; filename=test.xlsx"

output.close()

return response

Local setup response header :

Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Server response header :

content-type: text/html; charset=UTF-8

Any Idea why ?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.