Django管道不压缩
问题描述:
我刚刚安装Django管道到我的Django应用程序,它似乎并没有压缩我的JavaScript文件。它似乎正确安装,因为模板标签正常工作。我正在使用manage.py collectstatic来压缩文件。这是我目前的配置。我还设置了我的应用程序,以使用Django 1.3中的每个django-pipeline文档使用django-staticfiles。Django管道不压缩
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'site_media', 'static')
STATIC_URL = '/site_media/static/'
ADMIN_MEDIA_PREFIX = '/site_media/static/admin/'
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, "media"),
)
STATICFILES_FINDERS = (
##Turn these on if using django.contrib.staticfiles
##'django.contrib.staticfiles.finders.FileSystemFinder',
##'django.contrib.staticfiles.finders.AppDirectoriesFinder',
##'django.contrib.staticfiles.finders.DefaultStorageFinder',
##Turn these on if using django.contrib.staticfiles
'staticfiles.finders.FileSystemFinder',
'staticfiles.finders.AppDirectoriesFinder',
'staticfiles.finders.DefaultStorageFinder'
)
PREREQ_APPS = [
# Django
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
#External
'south',
'staticfiles',
'pipeline',
]
PIPELINE_YUI_BINARY='/Applications/yuicompressor-2.4.7/build/yuicompress'
PIPELINE_JS = {
'site': {
'source_filenames': (
'js/libs/ddsmoothmenu.js',
'js/script.js',
),
'output_filename': 'js/script.min.js',
}
}
我不确定我在这里错过了什么,但我确定它是某种东西。我没有收到任何错误消息或任何东西,它只是不压缩。
感谢您的帮助!
答
难道你设置staticfiles:
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
如果是:
你的JS文件最终是空的?
是
'/Applications/yuicompressor-2.4.7/build/yuicompress'
可执行脚本?
+0
这似乎是问题所在。我没有正确设置STATICFILES_STORAGE。我假设默认是好的。谢谢你的帮助! – ralph 2012-04-18 14:17:52
现在不应该使用'django.contrib.staticfiles',因为它包含在标准的Django发行版中? – Cerin 2013-05-15 19:33:31
@Cerin你是对的,我刚刚解决了这个问题。我不再使用django-staticfiles,而是使用contrib。 – ralph 2013-05-17 23:29:24