使用ManifestFilesMixin失败的collectstatic

时间:2019-04-04 07:33:33

标签: django django-staticfiles

我正在使用ManifestFileMixin对我的静态文件进行版本控制,然后再上传到Google云存储中

下面是自定义存储类

class CustomStorage(ManifestFilesMixin, S3Boto3Storage):
     pass

在settings.py

STATICFILES_STORAGE = 'myapp.storage.CustomStorage'

这是堆栈跟踪:

.venv/lib/python3.6/site-packages/storages/backends/s3boto3.py:282: UserWarning: The default behavior of S3Boto3Storage is insecure and will change in django-storages 2.0. By default files and new buckets are saved with an ACL of 'public-read' (globally publicly readable). Version 2.0 will default to using the bucket's ACL. To opt into the new behavior set AWS_DEFAULT_ACL = None, otherwise to silence this warning explicitly set AWS_DEFAULT_ACL.
 "The default behavior of S3Boto3Storage is insecure and will change "
 Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line 
   utility.execute()
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute 
   self.fetch_command(subcommand).run_from_argv(self.argv)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv 
   self.execute(*args, **cmd_options)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
   output = self.handle(*args, **options)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
   collected = self.collect()
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 128, in collect
   for original_path, processed_path, processed in processor:
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 402, in post_process
   yield from super().post_process(*args, **kwargs)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 236, in post_process
   for name, hashed_name, processed, _ in self._post_process(paths, adjustable_paths, hashed_files):
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 293, in _post_process
   content = pattern.sub(converter, content)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 194, in converter
   force=True, hashed_files=hashed_files,
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 131, in _url
   hashed_name = hashed_name_func(*args)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 342, in _stored_name
   cache_name = self.clean_name(self.hashed_name(name))
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 99, in hashed_name
   file_hash = self.file_hash(clean_name, content)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 79, in file_hash
   for chunk in content.chunks():
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/core/files/base.py", line 55, in chunks
  self.seek(0)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/django/core/files/utils.py", line 20, in <lambda>
   seek = property(lambda self: self.file.seek)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/storages/backends/s3boto3.py", line 97, in _get_file
   self.obj.download_fileobj(self._file)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/boto3/s3/inject.py", line 760, in object_download_fileobj
   ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/boto3/s3/inject.py", line 678, in download_fileobj
   return future.result()
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/s3transfer/futures.py", line 106, in result
   return self._coordinator.result()
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/s3transfer/futures.py", line 265, in result
   raise self._exception
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/s3transfer/tasks.py", line 255, in _main
   self._submit(transfer_future=transfer_future, **kwargs)
 File "/home/ufaz/webapps/ufaz_website/.venv/lib/python3.6/site-packages/s3transfer/download.py", line 348, in _submit
   response['ContentLength'])
 KeyError: 'ContentLength'

提醒一下。我正在使用Google Cloud Storage,因为它也与S3兼容

0 个答案:

没有答案