I am creating a web application in django when I wanted to create a static file download with html. I went into urls.py and modified it to have this at the end: static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Then I added this to index.html:
{% load static %}
<a href={% static "file.zip" %} download>Download File</a>
Then I added these lines to mysite.settings:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
I then went into my base directory and added a directory called static. I added the file file.zip into that directory, then went to the terminal and did a cd to the base directory. Finally, I run the command: python3 manage.py runserver I then go to the server adress and click Download File. At the bottom of the browser I then see: File.zip Failed- no file So I look back to the terminal and I see: "GET /static/file.zip HTTP/1.1" 404 1760 in orange. I see that this has a 404 at the end, so i look to stack overflow. I have spent days finding the answer, and so far i have tried: Django Static files 404 Download static file displayed in the list Django https://docs.djangoproject.com/en/3.0/howto/static-files/ How do you make a working static file download with html and django? Any working answer is appreciated! Thanks!