简体   繁体   中英

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:

图片

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.

based on django docs about static files try this:

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

this is old but in Django, when you have checked your code and you are sure every piece is where its meant to be, issues like this might be because you have not made migrations. in your terminal run python manage.py makemigrations python manage.py migrate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM