shevdenvla
shevdenvla

Reputation: 55

File csv does not downloaded but instead open inside browser

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

Answers (1)

Tim Nyborg
Tim Nyborg

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

Related Questions