简体   繁体   中英

Heroku, Django Collectstatic causing error

I am new to Heroku and I have been asked to look at someone's project hosted there (their previous supplier is not available).

This is a Django 1.4 project.

In order to learn if I've downloaded the project and loaded it to a new Heroku app. Works fine, but I've had to set disable_collectstatic = 1 due to an error. The original app is using an amazon s3 bucket for the static files so I can use those and all ok.

I'm now trying to setup my own s3 bucket and have it create the static files there. I'm getting the following traceback

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"

Interestingly I get the same ImproperlyConfigured error if I try and access admin from my 'new' project.

What is the cause of this and what am I missing?

So the problem here, which @e4c5 pointed towards, was packages being out of sync. The problem wasn't boto but django-storages . The requirements.txt file has django-storages==1.2a but that isn't being found so I went with v1.4. When I worked through the code, I realised I needed to go backwards to 1.1.8 to get compatibility. Now sorted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM