【发布时间】:2012-10-03 16:09:29
【问题描述】:
所以在过去的一个小时里,我一直在碰壁,似乎无法弄清楚为什么在我的模板被渲染时没有静态媒体(CSS、图像、JS 等)。 有人可以帮我找出我需要进行调整的原因吗?以下是来自 Settings.py、Index.html 和样式表的 sn-ps,如果需要更多信息,请告诉我。
我的静态文件位于以下目录: /djangoproject/网站/静态
Settings.py - Located /djangoproject/djangoprojectname/
STATIC_ROOT = os.path.normpath(os.path.join(PROJECT_ROOT,
"/static/"))
STATIC_URL = '../website/static/'
这是我 index.html 中的一个 sn-p,它应该使用 {{ STATIC_URL }}
调用 css 样式表Index.html - Location /djangoproject/website/templates/
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css">
CSS 样式表的位置
style.css - Location /djangoproject/website/static/css/
【问题讨论】:
-
页面渲染时,你在模板中
{{ STATIC_URL }}所在的源代码中看到了什么? -
/projects/djangoproject/website/static/css/style.css 据我所知,这是正确的路径......它仍然没有拉文件......有什么东西我应该可能会添加到 urls.py 或其他东西?