Install 100:
- 运行
pip install django-static-precompiler
分钟
- 向已安装的应用程序添加
static_precompiler
个
Install 100 executable,通过您的软件包管理器或运行npm install less
(npm is node package manager,应该是可分发安装的,最后使用)
Use less in templates:
- Load the template tag:
{% load less %}
- Use less template tag:
<link rel="stylesheet" href="{{ STATIC_URL}}{% less "path/to/styles.less" %}" />
默认情况下,Note that编译后的文件保存在STATIC_ROOT
下的COMPILED
文件夹中(如果设置中没有STATIC_ROOT
,则保存到MEDIA_ROOT
文件夹中).您可以使用STATIC_PRECOMPILER_OUTPUT_DIR
设置更改此文件夹名称.有关详细信息,请参阅documentation.
我没有亲自试过,但我知道django-compressor也支持较少.