Whitenoise,Mezzanine,Django -ImportError:无法导入名称ManifestStaticFilesStorage

时间:2016-09-02 18:14:37

标签: python django heroku gunicorn mezzanine

我正在尝试在heroku上部署我的夹层项目。最后一个错误给了我一个终极堆栈 - ImportError:无法导入名称ManifestStaticFilesStorage。这是我的核心项目结构:

├── deploy
│   ├── crontab
│   ├── gunicorn.conf.py.template
│   ├── local_settings.py.template
│   ├── nginx.conf
│   └── supervisor.conf
├── dev.db
├── fabfile.py
├── flat
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   ├── views.py
│   └── views.pyc
├── __init__.py
├── __init__.pyc
├── manage.py
├── Procfile
├── README.md
├── requirements.txt
├── runtime.txt
├── settings.py
├── staticfiles -> mezzanine_heroku/staticfiles
├── urls.py
├── urls.pyc
└── wsgi.py

wsgi.py:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

application = get_wsgi_application()
application = DjangoWhiteNoise(application)

Procfile:

web: gunicorn wsgi

来自heroku-logs的回溯:

ImportError: cannot import name ManifestStaticFilesStorage

2016-09-02T18:02:36.124458+00:00 app[web.1]: Traceback (most recent call last):
2016-09-02T18:02:36.124494+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2016-09-02T18:02:36.124529+00:00 app[web.1]:     sys.exit(run())
2016-09-02T18:02:36.124558+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2016-09-02T18:02:36.124620+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2016-09-02T18:02:36.124646+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 192, in run
2016-09-02T18:02:36.124706+00:00 app[web.1]:     super(Application, self).run()
2016-09-02T18:02:36.124709+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2016-09-02T18:02:36.124754+00:00 app[web.1]:     Arbiter(self).run()
2016-09-02T18:02:36.124800+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 218, in run
2016-09-02T18:02:36.124858+00:00 app[web.1]:     self.halt(reason=inst.reason, exit_status=inst.exit_status)
2016-09-02T18:02:36.124862+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 331, in halt
2016-09-02T18:02:36.124962+00:00 app[web.1]:     self.stop()
2016-09-02T18:02:36.124966+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 381, in stop
2016-09-02T18:02:36.125047+00:00 app[web.1]:     time.sleep(0.1)
2016-09-02T18:02:36.125057+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 231, in handle_chld
2016-09-02T18:02:36.125138+00:00 app[web.1]:     self.reap_workers()
2016-09-02T18:02:36.125141+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 506, in reap_workers
2016-09-02T18:02:36.125241+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2016-09-02T18:02:36.125304+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2016-09-02T18:02:36.182785+00:00 heroku[web.1]: State changed from starting to crashed
2016-09-02T18:02:36.175782+00:00 heroku[web.1]: Process exited with status 1

最令人困惑的是ImportError: cannot import name ManifestStaticFilesStorage错误。

1 个答案:

答案 0 :(得分:1)

ManifestStaticFilesStorage是在Django 1.7中引入的。你使用的是旧版本的Django吗?如果是这样,您应升级到supported version

仍然可以将WhiteNoise 2.0.6与旧版本的Django一起使用,但我或Django团队都不支持此功能。