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', 
    } 
} 

我不确定我在这里错过了什么,但我确定它是某种东西。我没有收到任何错误消息或任何东西,它只是不压缩。

感谢您的帮助!

+0

现在不应该使用'django.contrib.staticfiles',因为它包含在标准的Django发行版中? – Cerin 2013-05-15 19:33:31

+0

@Cerin你是对的,我刚刚解决了这个问题。我不再使用django-staticfiles,而是使用contrib。 – ralph 2013-05-17 23:29:24

难道你设置staticfiles:

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' 

如果是:

  • 你的JS文件最终是空的?

  • '/Applications/yuicompressor-2.4.7/build/yuicompress'可执行脚本?

+0

这似乎是问题所在。我没有正确设置STATICFILES_STORAGE。我假设默认是好的。谢谢你的帮助! – ralph 2012-04-18 14:17:52

你在你的设置中有DEBUG=True吗?尝试添加PIPELINE=True,以确保它运行压缩

+0

我已经尝试了这两个,但仍然没有运气。当我打开PIPELINE标志和DEBUG标志时,它会查找压缩文件,但实际上并没有对其进行压缩。 – ralph 2012-04-18 11:36:08

+0

听起来这可能是一个权限问题。你在开发中还是在生产服务器上? – 2012-04-18 11:37:45

+0

我在django开发服务器上运行。我已经检查了YUI Compressor以确保所有的dir确保所有的权限设置正确。我的第一个猜测是,它没有正确调用YUICompressor,但由于没有错误消息,我不知道它在做什么。 – ralph 2012-04-18 11:58:38