Search code examples
javascripthtmldjangodjango-staticfiles

Django - Not Recognizing Javascript File - Problem with Static?


When I try to go to five_day_forecast.html I'm getting the error:

127.0.0.1/:3 GET http://127.0.0.1:8000/five_day/static/capstone/five_day.js net::ERR_ABORTED 404 (Not Found)

It's not recognizing my Javascript file but I don't know why.

Here is how my files are setup, I'm using Django:

pic

five_day_forecast.html currently is just:

HELLO

<script src="static/capstone/five_day.js"></script>

I've tried having all my code there as well, or just this, and it still doesn't work. I don't understand because when I'm on home.html (which calls temp.js file) it works totally fine. And both js files are under static/capstone. I just don't know why it's not recognizing the js file here.


Solution

  • based on django docs about static files try this:

    <script src="{% static 'capstone/five_day.js' %}"></script>