0

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

Community
  • 1
  • 1
Elroum
  • 327
  • 1
  • 3
  • 18
  • If your files exists in the correct directory, and you're getting a 404 error. It's typically because your STATIC_URL in settings.py is set incorrectly. I'd also recommend using a content delivery network for the files instead of a file stored on the server. – user1470034 Mar 27 '18 at 13:51
  • Thank you so much for your replay ; this is my STATIC_URL = '/static/' , and in the beginning of my template i loaded staticfiles : {% load staticfiles %} – Elroum Mar 27 '18 at 13:54
  • Thank You So much , it's okey i just noticed that i forgot a directory in my url to dynamic-formset.js – Elroum Mar 27 '18 at 13:59

1 Answers1

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

Ochui Princewill
  • 148
  • 1
  • 15