我正在尝试在 heroku 上部署我的夹层项目。最后一个错误给了我一个最终的堆栈——ImportError: cannot import name 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)
简介:
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
错误。
最佳答案
ManifestStaticFilesStorage 是在 Django 1.7 中引入的。您使用的是旧版本的 Django 吗?如果是这样,您应该升级到 supported version .
仍然可以使用 WhiteNoise 2.0.6使用旧版本的 Django,但我或 Django 团队都不支持。
关于python - Whitenoise、Mezzanine、Django -ImportError : cannot import name ManifestStaticFilesStorage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39298540/