【发布时间】:2015-05-10 16:34:23
【问题描述】:
我想使用 django_compressor,但它在我的生产环境中不起作用。
在开发中 (DEBUG=True),它正在工作并创建了 .sass-cache 和 CACHE 文件夹。
我的settings.py 是
DEBUG = False
TEMPLATE_DEBUG = False
INSTALLED_APPS = (
...,
'django.contrib.staticfiles',
'compressor',
'myapp',
)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'com.app.static')↲
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)
COMPRESS_ENABLED = True
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'sass --scss {infile} {outfile}'),
)
MEDIA_URL = '/media/'
scss文件将模板目录放到app上。
{% load staticfiles %}
{% load compress %}
<html>
<head>
{% compress css %}
<link rel='stylesheet' type='text/scss' href="{% static 'top/css/top.scss' %}" charset='utf-8'>
{% endcompress %}
</head>
</html>
【问题讨论】:
标签: python django django-compressor