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