Django模板CSS / IMG在URL中“关闭”

时间:2012-05-31 04:36:47

标签: django django-templates

我有

/path/to/my/theme/static/css/frontend.css

由base.html调用

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/frontend.css" media="all" />

我有一个标题背景:

#header-wrapper 
        min-width: 960px;
        height: 150px;
        background: transparent url(img/header-bg.png) repeat-x center bottom;
}

文件是

/path/to/my/theme/static/img

我运行了manage.py collectstatic来收集文件,几乎所有内容看起来都正确,除了生成的链接如下:http://example.com/static/css/img/header-bg.png

图片未显示,因为正确的网址为:http://example.com/static/img/header-bg.png

我哪里错了?

1 个答案:

答案 0 :(得分:1)

url()与css文件的路径相关:也许您可以使用url(../img/header-bg.png)