1

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.

Tyler Bell
  • 837
  • 10
  • 30
  • Can you make your question clearer? Which part of the process are you struggling with? If you're using Django's FileField, it will manage filenames and make sure nothing's overwritten on the server side. – raphv Jun 10 '16 at 19:02

1 Answers1

0

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?

Community
  • 1
  • 1
Dipanjan
  • 1
  • 1
  • 3