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

标签 python django django-compressor

当使用 compress templatetags PROJECT_PATH 时,我使用 django-compressor 1.1.2Django 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' 尝试。

关于python - Django 1.4 和 django-compressor 奇怪之处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11149867/

相关文章:

django - 使用 django_compressor 将文件压缩为 gzip

python - 带有压缩静态文件的 Django Whitenoise

python - YoloV5s如何从推理时间输出FPS

python - 无法在python中使用posix风格的时区解析解析时间字符串

python - 使用 Django View 将每 3 个对象分组到单独的上下文变量中?

django-compressor + less 压缩文件但链接到原始文件

python - 如何从列表中检索最小唯一值?

python - 如何在 python 中从 LAB (l*a*b) 颜色空间中获取 a channel

database - 为什么 Django 不从模型创建完整表?

python - 保存模型时去除空格