python - Django Compressor 空白 Css 输出文件

标签 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) 总是空的!

最佳答案

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

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

查看此问题:https://github.com/jezdez/django_compressor/pull/177

关于python - Django Compressor 空白 Css 输出文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8899913/

相关文章:

java - 从大小 > 10GB 的大文件中读取行范围的快速方法

html - 如何制作类似 Twitter-Bootstrap 的按钮

css - 字体在 GoogleFonts 上的呈现方式与在我的页面上呈现的方式不同

python - 如何在 Django 模板中从 Matplotlib 输出图形?

python - 带有函数和结构指针的 ctypes 中的错误

python - python-xdist 插件是否会导致 pytest_generate_tests 执行多次?

python - Flask - 嵌套的 rest api - 使用 methodview 以外的东西或者我做了一个糟糕的设计?

javascript - 下拉按钮列表。 Onmousover 在右侧显示按钮说明

Python Django 1.6 在查看之前为每个请求执行函数

python - Django ModelForm 从其他字段创建字段