Heroku can't find my 'settings.py' file

纵饮孤独 提交于 2020-01-03 05:20:10

问题


After deploying my django project on heroku get this in logs:

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 contains here: django_structure->src->django_structure.

Procfile:

web: gunicorn django_structure.src.django_structure.wsgi

Wsgi.py:

s.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_structure.settings")

Project link: https://github.com/AlfredMulder/Django_work


回答1:


Since your Django project is not in the root of your repository, you need to add the directory to the python path:

web: gunicorn --pythonpath django_structure/src django_structure.wsgi


来源:https://stackoverflow.com/questions/49457037/heroku-cant-find-my-settings-py-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!