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

时间:2012-07-10 20:56:09

标签: django amazon-web-services

我正在尝试部署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

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

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

根据django-storage docs,在s3存储桶中设置collectstatic放置文件的正确方法是在设置中定义以下内容:

STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

... 你不能使用storeages.backends.s3.s3Storage因为后端没有定义listdir方法...... boto后端会这样做。

相关问题