Created
May 3, 2020 22:06
-
-
Save mpampols/5e057af32274fd4e4cd4ef82c120e90a to your computer and use it in GitHub Desktop.
download_docx.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save document to memory and download to the user's browser | |
document_data = io.BytesIO() | |
document.save(document_data) | |
document_data.seek(0) | |
response = HttpResponse( | |
document_data.getvalue(), | |
content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document", | |
) | |
response["Content-Disposition"] = 'attachment; filename = "Carta de Presentación.docx"' | |
response["Content-Encoding"] = "UTF-8" | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment