Django Compressor空白Css输出文件

时间:2012-01-17 18:43:06

标签: python css django compression

当django压缩css时,它会将输出保存到/static/CACHE/css/[filename].css中的文件中,但无论我尝试什么,css文件都会一直空白!

在我的模板中......

{% compress css %}
<link rel='stylesheet' type='text/less' href='{{ STATIC_URL }}css/deals_for_you.less'/>
{% endcompress %}

我成功安装了django_compressor,django_appconf和versiontools 我成功安装了lessc(testecd) STATICFILES_FINDERS已设置

COMPRESS_OFFLINE = True
COMPRESS_ENABLED = True
COMPRESS_OFFLINE_CONTEXT = {
    'STATIC_URL': STATIC_URL,
}
COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} {outfile}'),
)

另外,当我跑

python manage.py compress

输出......

Found 'compress' tags in:
    [/my/file/path]/index.html
Compressing... done
Compressed 1 block(s) from 1 template(s)

但是我得到的输出文件(在/static/CACHE/css/d41d8cd98f00.css) 永远是空的!

1 个答案:

答案 0 :(得分:0)

您是通过npm还是通过ruby gem安装的?如果是后者,请尝试更新为:

COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} > {outfile}'),
)

请参阅此问题:https://github.com/jezdez/django_compressor/pull/177