【发布时间】:2016-09-29 15:15:45
【问题描述】:
据我所知,我已按照所有步骤正确加载我的静态文件。我能够在 the instructions here 之后的模板中加载 jpg:
但是,我的静态文件夹中的 Javascript 文件没有加载。
这是我的 base.html:
<!DOCTYPE html>
{% load staticfiles %}
<html>
<head>
{% block js %}
<script src="{% static "js/p5" %}"></script>
{% endblock %}
<title>Rango</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
在 settings.py 我有:
STATIC_DIR = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [STATIC_DIR, ]
我肯定有p5.js 位于/static/js/p5.js,并且 django.contrib.staticfiles 在我安装的应用程序中。当我访问从 base.html 继承的任何站点时,firebug 显示没有加载任何 JS 文件。我做错了什么?
【问题讨论】:
-
<script src="{% static "js/p5" %}"></script>到<script src="{% static "js/p5.js" %}"></script>?