【问题标题】:Heroku, Django Collectstatic causing errorHeroku,Django Collectstatic导致错误
【发布时间】:2017-06-04 07:12:07
【问题描述】:

我是 Heroku 的新手,我被要求查看某人在那里托管的项目(他们以前的供应商不可用)。

这是一个 Django 1.4 项目。

为了了解我是否已下载该项目并将其加载到新的 Heroku 应用程序中。工作正常,但由于错误,我不得不设置 disable_collectstatic = 1。原始应用程序使用 amazon s3 存储桶存储静态文件,因此我可以使用它们,一切正常。

我现在正在尝试设置我自己的 s3 存储桶并让它在那里创建静态文件。我得到以下回溯

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 70, in load_command_class
    return module.Command()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 57, in __init__
    self.storage.path('')
  File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 279, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 277, in get_storage_class
    raise ImproperlyConfigured('Error importing storage module %s: "%s"' % (module, e))
django.core.exceptions.ImproperlyConfigured: Error importing storage module storages.backends.s3boto: "cannot import name force_bytes"

有趣的是,如果我尝试从我的“新”项目访问管理员,我会遇到同样的 ImproperlyConfigured 错误。

这是什么原因,我错过了什么?

【问题讨论】:

  • Django 1.4 已经很老了。自从 django 进入 1.4 以来,Boto 已经走了很长一段路。虽然它的较新版本与较新版本的 django 兼容,但这些旧版本可能并非如此。看看你是否能找到最初使用的版本并安装它。
  • 我在 requirements.txt 中有 boto==2.6.0,这是 2012 年的版本

标签: python django heroku amazon-s3


【解决方案1】:

所以@e4c5 指出的问题是包不同步。问题不是博托而是django-storagesrequirements.txt 文件有 django-storages==1.2a 但没有找到,所以我选择了 v1.4。当我处理代码时,我意识到我需要回退到 1.1.8 才能获得兼容性。现已排序。

【讨论】:

    猜你喜欢
    • 2015-07-17
    • 2021-05-13
    • 2017-05-30
    • 1970-01-01
    • 2014-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-08
    相关资源
    最近更新 更多