我的django在尝试获取jquery-2.2.4.js
文件时收到404错误。但是,它正在使css/boardcss.css
文件正常,即使它们在执行collectstatic之后都在相同的顶级/静态/文件夹中。有什么帮助吗?
以下是运行我的网站时出现的jquery 404错误:
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
我的HTML文件:
{% 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>
来自我的settings.py文件:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "board", "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, "static")
我的目录树:
答案 0 :(得分:1)
您可能需要配置:
https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-STATICFILES_FINDERS
[
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
查找如何查找静态文件的finder后端列表 各个地方。