Reputation: 1021
My django is getting a 404 error when trying to get the jquery-2.2.4.js
file. However, it is getting the css/boardcss.css
file just fine, even though they are both in the same top-level /static/ folder, after doing collectstatic. Any help?
Here is the jquery 404 error when I run my site:
Django version 1.9.6, using settings 'tictactoe.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[06/Jun/2016 23:04:21] "GET /board/ HTTP/1.1" 200 361
[06/Jun/2016 23:04:21] "GET /static/jquery-2.2.4.js HTTP/1.1" 404 1658
[06/Jun/2016 23:04:21] "GET /static/css/boardcss.css HTTP/1.1" 304 0
My HTML file:
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="{% static 'jquery-2.2.4.js' %}">
</script>
<link rel="stylesheet" href="{% static 'css/boardcss.css' %}">
</head>
<body class="body" style="background-color:#545454">
<div class='container-fluid'>
{% block content %}
{% endblock %}
</div>
</body>
</html>
From my settings.py file:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "board", "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, "static")
My directory tree:
Upvotes: 3
Views: 2094
Reputation: 2403
ok, so you have 2 static folders. I believe that is your problem. note when you go up one level and then look for static, in one of them you have a jquery file and the other you don't.
you might need to configure:
https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-STATICFILES_FINDERS
[
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
The list of finder backends that know how to find static files in various locations.
Upvotes: 1