I'm trying to add javascript static file in to my html. But i couldn't
<html>
<head>
<title>SpaceX</title>
<script src="static/js/script.js" ></script>
</head>
<body>
<img src="static/img/img.jpg">
</body>
</html>
Image is working correctly but the JS is not
Url:
from django.contrib import admin
from django.urls import path, include
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
path('admin/', admin.site.urls),
path('spacex/', include('spacex.urls'),
)
]
urlpatterns += staticfiles_urlpatterns()
Script
alert('abc') ;
Setting:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
And on powershell
[28/Dec/2019 19:12:20] "GET /spacex/ HTTP/1.1" 200 166
[28/Dec/2019 19:12:20] "GET /spacex/static/js/script.js HTTP/1.1" 304 0
Saying like that so what's the problem can you help me ?