matilde
matilde

Reputation: 25

Problem downloading files in django template

I'm trying to download a file from a local directory in a Django template, but when I click and download it, I get a File Not Found error on my browser. As soon as I click download, the file explorer to choose the folder opens, but when I save the file I get that error. The path to the file I'm sure is right.

index.html

<a href="path_to_file" download target="_blank">Download</a>

Upvotes: 0

Views: 632

Answers (1)

cshelly
cshelly

Reputation: 615

Django doesn't serve static files by itself.

In order to create a file download link, you need to have a Django view that serves the static file. Refer here for more details https://djangoadventures.com/how-to-create-file-download-links-in-django/

Upvotes: 1

Related Questions