【问题标题】:Heroku can't find my 'settings.py' fileHeroku 找不到我的“settings.py”文件
【发布时间】:2018-09-02 13:34:57
【问题描述】:

在 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->src->django_structure。

过程文件:

web: gunicorn django_structure.src.django_structure.wsgi

Wsgi.py:

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

项目链接: https://github.com/AlfredMulder/Django_work

【问题讨论】:

    标签: python django python-3.x heroku django-2.0


    【解决方案1】:

    由于你的 Django 项目不在你的仓库根目录下,你需要将目录添加到 python 路径中:

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

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 2017-08-07
      • 1970-01-01
      • 1970-01-01
      • 2019-04-01
      • 2021-01-19
      • 2012-09-28
      • 1970-01-01
      • 2017-07-12
      相关资源
      最近更新 更多