【发布时间】:2013-05-21 16:30:57
【问题描述】:
在我的 settings.py 中,我已经设置了 staticfiles_dirs
STATICFILES_DIRS = (
os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'static')).replace('\\','/')
)
在 myproject/static 文件夹中,我有一个名为 jquery-1.10.0.js 的文件。我试图像这样在我的应用程序模板中加载文件
{% load static %}
<script type="text/javascript" src="{% static "jquery-1.10.0.js" %}"></script>
但我无法从我的模板中访问 jquery 函数,如果我转到 {% static "jquery-1.10.0.js" %} 返回的 url,即 /static/jquery-1.10.0.js,我会看到一个页面显示发生服务器错误.请联系管理员。
如何从模板中访问 jquery 文件?
【问题讨论】:
-
哪个版本的 Django?调试模式是否开启?控制台有错误吗?
-
你不能只做
/static/jquery-1.10.0.js吗?
标签: python django django-templates static-files