我正在尝试让 django-pipeline 在 Windows 上本地工作。当我运行 collectstatic 或 runserver 并转到该站点时,我收到以下错误:
NotADirectoryError at /
[WinError 267] The directory name is invalid
在网站上,它{% compressed_css 'main' %}
在模板中被调用时发生。
查看回溯,它似乎发生在pipeline\compilers\__init__.py
这一行:return list(executor.map(_compile, paths))
,带有本地变量:
futures <module 'concurrent.futures' from 'C:\\Python34\\Lib\\concurrent\\futures\\__init__.py'>
force False
_compile <function Compiler.compile.<locals>._compile at 0x0387A858>
paths ['sass/main.sass']
multiprocessing <module 'multiprocessing' from 'C:\\Python34\\Lib\\multiprocessing\\__init__.py'>
executor <concurrent.futures.thread.ThreadPoolExecutor object at 0x0387B970>
self <pipeline.compilers.Compiler object at 0x0387B870>
相关的settings.py块:
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATICFILES_DIRS = (
(os.path.join(BASE_DIR, 'static/common')),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
# Pipeline
PIPELINE_SASS_BINARY = 'sass'
PIPELINE_YUGLIFY_BINARY = 'yuglify'
PIPELINE_COMPILERS = (
'pipeline.compilers.sass.SASSCompiler',
)
PIPELINE_CSS = {
'main': {
'source_filenames': (
'sass/main.sass',
),
'output_filename': 'css/main.css'
}
}
sass 和 yuglify 都从命令行工作。
相关文件系统结构:
myproject/
...
settings.py
static/
common/
sass/
main.sass
如果我取出PIPELINE_COMPILERS = (...)
并使用它来缩小常规 CSS 文件,它会完美运行。