2
我曾经使用django-pipeline 1.2.6,它从来没有找到静态文件的问题。升级之后,它现在无法找到静态文件所在的位置。不知道什么是错的,但我可能只是错过了一些东西。将django-pipeline升级到1.2.7,但找不到静态文件
ValueError: The file 'stylesheets/application.css.sass' could not be found with <pipeline.storage.PipelineFinderStorage object at 0x106e8b290>.
我使用Django 1.4:
我得到这个错误。这里是我的设置:
path = lambda *a: os.path.join(ROOT_PATH, *a)
MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = path('assets/')
STATIC_URL = 'assets/'
STATICFILES_DIRS =()
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
INSTALLED_APPS = (
# ...
'django.contrib.staticfiles',
'pipeline',
'app',
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_COMPILERS = (
'pipeline.compilers.sass.SASSCompiler',
'pipeline.compilers.coffee.CoffeeScriptCompiler',
)
PIPELINE_CSS = {
'application': {
'source_filenames': (
'stylesheets/application.css.sass',
),
'output_filename': 'stylesheets/application.css',
},
}
PIPELINE_JS = {
'application': {
'source_filenames': (
'javascripts/application.js.coffee',
),
'output_filename': 'javascripts/application.js',
}
}
请帮忙。
有趣的小知识:如果我完全删除PIPELINE_CSS,它也找不到javascripts/application.js.coffee。
另一个有趣的事情,不管我用哪个Django的管道的版本,我得到如下:
$ python manage.py findstatic stylesheets/application.css.sass
No matching file found for 'stylesheets/application.css.sass'.
我在做什么错?
它存储在{project dir}/assets下的整个项目的静态目录中。 – Kenneth
你不能在''STATIC_ROOT'',''staticfiles''内存储你的静态文件,应该向你发出警告。 – cyberdelia
太棒了!我将静态根改为public,findstatic现在可以工作,最新的django-pipeline也是如此。谢谢cyberdelia! – Kenneth