gpt4 book ai didi

Django collectstatic 无法使用 django-storages(使用 AWS)

转载 作者:行者123 更新时间:2023-12-04 05:39:35 27 4
gpt4 key购买 nike

我正在尝试部署 django 站点,但无法获取 manage.py collectstatic命令来完成。它收集了大部分文件但从未完成...返回以下回溯。我正在使用 django1.3 和 python2.7。

另外,DEBUG = False'django.contrib.staticfiles'在我安装的应用程序中。

追溯:

Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/rowapparel/.virtualenvs/dev_ra_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 "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 80, in handle_noargs
for path, storage in finder.list(ignore_patterns):
File "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 210, in list
for path in utils.get_files(self.storage, ignore_patterns):
File "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 21, in get_files
directories, files = storage.listdir(location)
File "/home/rowapparel/.virtualenvs/dev_ra_env/lib/python2.7/site- packages/django/core/files/storage.py", line 109, in listdir
raise NotImplementedError()
NotImplementedError

同样,它适用于我的许多静态文件,但不是全部。它似乎每次都停在同一个文件上,但是当我忽略该应用程序和/或文件时,它仍然返回上述回溯。

有什么想法吗?

最佳答案

根据 django-storages docs ,将 collectstatic put 文件放入 s3 存储桶的正确方法是在设置中定义以下内容:
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
... 你不能使用 storeages.backends.s3.s3Storage因为该后端没有定义 listdir 方法...... boto 后端有。

关于Django collectstatic 无法使用 django-storages(使用 AWS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11421809/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com