简体   繁体   中英

Django, How to allow users to download a Python generated file

I am new to Django and have a few questions.

I made a python program that requires user input, and a docx file. How do I allow that user to download their generated docx file? I am assuming I am going to have to work with temporary files since the program can not overwrite an existing docx file if there are multiple users on the site.

Thanks for your help.

Write the response with "Content-Type: application/octet-stream" and "Content-Disposition: attachment". Then write the updated file to the response.
For more exact mime types, check out: What is a correct mime type for docx, pptx etc?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM