部署到Heroku时指定项目根目录

Jok*_*ker 6 deployment django heroku

我的问题:

当使用gunicorn作为我的WSGI HTTP服务器时,工头无法找到Django(wsgi?)应用程序.

应用结构:

在我的Django应用程序中,我的结构如下:

<git_repository_root>/
  <django_project_root>/
    <configuration_root>/
Run Code Online (Sandbox Code Playgroud)

<git_repository_root>包含项目管理和部署有关的东西(requirements.txt,Procfile,fabfile.py等)

<django_project_root>包含我的Django的应用程序和应用程序逻辑.

最后,<configuration_root>包含我settings.pywsgi.py.

我尝试过的:

Procfile应该看起来像这样(根据Heroku Docs):

web: gunicorn myapp.wsgi

foreman start使用此项目布局运行时,出现错误:

ImportError: Import by filename is not supported.
Run Code Online (Sandbox Code Playgroud)

什么有效:

如果我将我的Procfile移动<git_repository_root><git_repository_root>它本地工作.在推送到Heroku之后(注意:Heroku看到<git_repository_root>)我无法扩展任何工人/添加进程.我得到以下内容:

Scaling web dynos... failed
 !    No such process type web defined in Procfile.
Run Code Online (Sandbox Code Playgroud)

我相信,我想Procfile在我<git_repository_root>反正虽然-那么,为什么不工作?我也尝试过Procfile改为: web: gunicorn myapp/myapp.wsgi

但没有运气.任何帮助将非常感激!

Nit*_*ked 1

Procfile向后移动<git_repository_root>并使用:

web: gunicorn <django_project_root>.myapp:myapp
Run Code Online (Sandbox Code Playgroud)

将最后的“myapp”替换为您的应用程序的类名,大概它确实是“myapp”。

...并阅读错误消息:它告诉您无法app通过文件名(myapp.wsgi)导入工作类(),所以当然说dirname/myapp.wsgi也不起作用。您需要 Pythonmodule:class语法。