django-pipeline not compressing

廉价感情. 提交于 2019-12-23 20:10:33

问题


I have just installed django-pipeline into my django application and it doesn't seem to be compressing my javascript files. It seems to be installed properly as the template tags are working correctly. I'm using manage.py collectstatic in order to compress the files. Here is my current configuration. I have also set up my app to use django-staticfiles per the django-pipeline docs as I'm using Django 1.3.

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

I'm not sure what I'm missing here, but I'm sure it is something. I am not getting any error messages or anything, it just isn't compressing.

Thanks for your help!


回答1:


Did you setup staticfiles with :

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

If yes :

  • Are you js files eventually empty ?

  • Is '/Applications/yuicompressor-2.4.7/build/yuicompress' an executable script ?




回答2:


Have you got DEBUG=True in your settings? Try adding PIPELINE=True to make sure it runs the compressions



来源:https://stackoverflow.com/questions/10202082/django-pipeline-not-compressing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!