我正在尝试将 django-pipeline-1.1.27 与 s3boto 一起使用来压缩和过滤静态文件,然后将它们上传到 s3 存储桶。如果我只是使用:
PIPELINE_STORAGE = 'pipeline.storage.PipelineFinderStorage'
然后它可以工作,我得到一个静态文件夹,其中包含我配置的漂亮版本文件。一旦我切换到
PIPELINE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
我明白了
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_manager(settings)
File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/management/commands/synccompress.py", line 39, in handle
packager.pack_stylesheets(package, sync=sync, force=force)
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/packager.py", line 52, in pack_stylesheets
**kwargs)
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/packager.py", line 60, in pack
package['output'], package['paths'])
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/versioning/__init__.py", line 45, in need_update
version = self.version(paths)
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/versioning/__init__.py", line 20, in version
return getattr(self.versioner, 'version')(paths)
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/versioning/hash/__init__.py", line 37, in version
buf = self.concatenate(paths)
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/versioning/hash/__init__.py", line 27, in concatenate
return '\n'.join([self.read_file(path) for path in paths])
File "/my/virtual/env/lib/python2.7/site-packages/pipeline/versioning/hash/__init__.py", line 31, in read_file
file = storage.open(path, 'rb')
File "/my/virtual/env/lib/python2.7/site-packages/django/core/files/storage.py", line 33, in open
file = self._open(name, mode)
File "/my/virtual/env/lib/python2.7/site-packages/storages/backends/s3boto.py", line 177, in _open
raise IOError('File does not exist: %s' % name)
IOError: File does not exist: css/style.css
这是我的源文件之一。那么为什么当我切换到 s3boto 存储时,管道不再想要执行过滤/连接/压缩步骤呢?
可能是我在做某事。如果有帮助,这是其他配置:
INSTALLED_APPS = (
...
'pipeline',
'storages',
)
STATICFILES_FINDERS = (
'pipeline.finders.PipelineFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
STATIC_ROOT = "/some/path/outside/django_project/deploy_static"
STATICFILES_DIRS = () # All statics in this site are in apps
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
PIPELINE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
PIPELINE = True
PIPELINE_AUTO = True
PIPELINE_VERSION = True
PIPELINE_VERSION_PLACEHOLDER = 'VERSION'
PIPELINE_VERSIONING = 'pipeline.versioning.hash.SHA1Versioning'
PIPELINE_CSS = {
'standard': {
'source_filenames': (
'css/style.css',
...
),
'output_filename': 'css/all-VERSION.css',
'extra_context': {
'media': 'screen,projection',
},
}
}
我的网站在 Django 1.3.1 上。
我正在运行的命令是:
python manage.py synccompress --force
AWS 信誉也在设置中,但这没有实际意义,因为它甚至还没有达到这一点。
更新添加了评论中要求的完整堆栈和设置
更新应图书馆作者的要求,我尝试升级到最新的测试版。到目前为止的观察结果:
- 我现在不知道如何获取版本化压缩文件
- collectstatic 给我留下了压缩文件和原件
- 配置 boto 存储时仍然从 django-pipeline 收到相同的错误:它想将我的源文件发送到 s3,但我什至看不到它在哪里暂存我的资产。STATIC_ROOT 中没有任何内容。
更新我创建了最简单的项目,适用于查找器存储,然后与 S3Boto 中断。我已将其推送到 github,并包含了堆栈跟踪的捕获。
https://github.com/estebistec/simple_pipeline https://raw.github.com/estebistec/simple_pipeline/master/STACKTRACE
如果有人告诉我我正在做一些非常愚蠢的事情,我会欣喜若狂,而这一切都应该奏效。