在heroku上部署我的django项目后,请在日志中获取:
File "/app/django_structure/src/django_structure/wsgi.py", line 16, in <module>
2018-03-23T12:09:10.575053+00:00 app[web.1]: application = get_wsgi_application()
2018-03-23T12:09:10.575056+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2018-03-23T12:09:10.575058+00:00 app[web.1]: django.setup(set_prefix=False)
2018-03-23T12:09:10.575061+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
2018-03-23T12:09:10.575064+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2018-03-23T12:09:10.575067+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
2018-03-23T12:09:10.575069+00:00 app[web.1]: self._setup(name)
2018-03-23T12:09:10.575072+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
2018-03-23T12:09:10.575075+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2018-03-23T12:09:10.575077+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__
2018-03-23T12:09:10.575080+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2018-03-23T12:09:10.575083+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2018-03-23T12:09:10.575085+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2018-03-23T12:09:10.591042+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_structure.settings'
Settings.py 此处包含:django_structure-&gt; src-&gt; django_structure。
Procfile:
web: gunicorn django_structure.src.django_structure.wsgi
Wsgi.py:
s.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_structure.settings")
答案 0 :(得分:0)
由于您的Django项目不在您的存储库的根目录中,您需要将目录添加到python路径:
web: gunicorn --pythonpath django_structure/src django_structure.wsgi