当我执行manage.py collectstatic时,django-pipeline FileNotFoundError

时间:2017-09-11 10:20:46

标签: django django-pipeline

这是追溯线的最后几行:

  File "C:\PycharmDev\TestVirtualEnv\testEnv1\lib\site-packages\pipeline\compressors\__init__.py", line 247, in execute_command
    stdin=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Python34\Lib\subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\Lib\subprocess.py", line 1112, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] ...

在settings.py中:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATIC_URL = '/static/'
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATIC_URL = '/static_prepared/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static_prepared'),
]
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)
PIPELINE = {
    'STYLESHEETS': {
        'static_prepared': {
            'source_filenames': (
              '*.css',
            ),
            'output_filename': 'colors.css'
        },
    },
    'JAVASCRIPT': {
        'static_prepared': {
            'source_filenames': (
              '*.js',
            ),
            'output_filename': 'stats.js',
        }
    }
}

我怎么了?

当我使用manage.py collectstatic时,它根本不适用于管道。

似乎只是没有管道。

与没有管道一样。正常manage.py collectstatic。

为什么发生错误?

我已经手动在os.path.join(BASE_DIR,...)上创建了static和static_prepared目录。

如何正确设置管道?

1 个答案:

答案 0 :(得分:1)

替换其他名称,如

PIPELINE = {
    'STYLE': {
        'static_prepared': {
            'source_filenames': (
              '*.css',
            ),
            'output_filename': 'colors.css'
        },
    },
    'JSCRIPT': {
        'static_prepared': {
            'source_filenames': (
              '*.js',
            ),
            'output_filename': 'stats.js',
        }
    }
}