Reputation: 55
I have two files that a user can download from my django app. The files have different formats xls and csv. The first one is downloaded as expected, but the problem is with csv, it is not downloaded, but opens inside the browser like a normal html. how can this be fixed?
I think I need to change the title from text/html to file/csv. But i don't know how i can do it.
Upvotes: 0
Views: 888
Reputation: 1649
Are you using a content disposition header to tell the browser that it's an attachment? Browsers can have different default actions for different file types.
response['Content-Disposition'] = 'attachment; filename="filename.csv"'
Upvotes: 1