Skip to main content
 首页 » 编程设计

python之Django 1.4 和 django-compressor 奇怪之处

2025年05月04日33Leo_wl

当使用 compress templatetags PROJECT_PATH 时,我使用 django-compressor 1.1.2 和 Django 1.4 STATIC_URL压缩后

/static/Users/sultan/.virtualenvs/mediabox/somedia/somedia/public/media/media-cache/compressor/css/1d7cd4216904.css 

当我不设置时 COMPRESS_OUTPUT_DIR = os.path.join(MEDIA_CACHE, 'compressor')

输出看起来像

/static/CACHE/css/1d7cd4216904.css 

设置

STATICFILES_FINDERS = ( 
    ... 
    'compressor.finders.CompressorFinder' 
) 
 
COMPRESS_ENABLED = True 
COMPRESS_OUTPUT_DIR = os.path.join(MEDIA_CACHE, 'compressor') 

我的配置有什么问题?

谢谢,

苏丹

请您参考如下方法:

根据 the doc

django.conf.settings.COMPRESS_OUTPUT_DIR  
Default :   'CACHE'  
Controls the directory inside COMPRESS_ROOT that compressed files will be written to.) 

我不知道你这里的MEDIA_CACHE设置是什么,但是你不需要加入目录来生成COMPRESS_OUTPUT_DIR,只需要给它一个相对的名字比如'compressor' 或 'cache' 尝试。