Please your help.. I spent hours to understand it
I started a very basic template with Django, and it can't find my js files, while it can find the css file - when both of them in static folder
Here is a link for the project (1.4MB)
Thanks a lot!
[11/Jun/2020 00:21:18] "GET /js/init.js HTTP/1.1" 404 2134
Not Found: /js/materialize.js
[11/Jun/2020 00:21:18] "GET /js/materialize.js HTTP/1.1" 404 2155
Not Found: /js/init.js
In Setting.py I have these settings:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = 'staticfiles'
This is my Project Dictionary: 3 folders - (1) home [the app] (2) project_folder (3) static - contain css, js, images
Found it. Obviously it was a small mistake that messed with the whole thing:
Even though I've added the JS at the top correctly like this:
<head>
...
<!-- JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type="text/javascript" src="https://drive.google.com/uc?export=view&id=11SXwFQpXEPJB6y_0aExroDW6VD97egRb"></script>
</head>
I had this code at the end of the HTML:
<!-- Scripts-->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/materialize.js"></script>
<script src="js/init.js"></script>
</body>
</html>
Fixed by:
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.