Django : static files are not loaded

三世轮回 提交于 2020-07-10 07:21:25

问题


i'm trying to test the code mentionned in this page : dynamic-formset.js and i added :

<script src="{% static  'js/dynamic-formset.js' %}"></script>
<script src="{% static  'js/jquery-3.3.1.js' %}"></script>

in order to load static files that contains js. howerver the js doesn't work and i'm getting in the console the following lines :

 "GET /static/js/dynamic-formset.js HTTP/1.1" 404 1777
 "GET /static/js/jquery-3.3.1.js HTTP/1.1" 404 1768

when i replace the second ligne that imports jquery with the https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js , i dont get :

"GET /static/js/jquery-3.3.1.js HTTP/1.1" 404 1768

i only get "GET /static/js/dynamic-formset.js HTTP/1.1" 404 1777

do you have any idea why it doesn't work ? i guess that the static files are not loading. Any help please ? Thank You


回答1:


If you are using django 2.x.x make sure your static files are in a sub folder inside the static folder that corresponds to your app name. See Other question



来源:https://stackoverflow.com/questions/49514132/django-static-files-are-not-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!