无法在 DjangoGirls 教程中部署到 Heroku

Can't deploy to Heroku in DjangoGirls tutorial

我正在关注这个 DjangoGirls 教程:http://tutorial.djangogirls.org/en/deploy/README.html

当我尝试打开我的应用程序的 /admin 页面时,因为教程指出:

"Since we only created the admin view for the app so far, add admin/ to the url (e.g. https://djangogirlsblog.herokuapp.com/admin/) to see a working page of our web app."

我仍然收到以下浏览器消息:

Application Error An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

这是我的项目布局:

djangogirls
|--mysite/
  |--blog/
  |--db.sqlite3
  |----manage.py
  |----mysite/
|--myvenv/
|--Procfile
|--requirements.txt
|--runtime.txt
|--.gitignore

这些是.gitignore的内容:

myvenv
__pycache__
staticfiles
local_settings.py
db.sqlite3
*.py[co]
*.pyc

这些是我的mysite/wsgi.py

的内容
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)

这些是Procfile的内容

web: gunicorn djangogirls.wsgi

教程说要复制出来mysite.wsgi,但是我在另一个post里看到应该是project_name.wsgi,所以就改了这个

runtime.txt: python-2.7.6

requirements.txt:

dj-database-url==0.3.0
Django==1.8
gunicorn==19.3.0
whitenoise==1.0.6
psycopg2==2.5.4

我知道这是一篇很长的文章 post 对此我提前表示歉意,我想提供更多的信息而不是不够的,我不完全明白我应该看哪些重要的东西在这种情况下!

这是我的 heroku 日志:

2015-04-07T02:30:18.990628+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 189, in run
2015-04-07T02:30:18.990685+00:00 app[web.1]:     super(Application, self).run()
2015-04-07T02:30:18.990710+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2015-04-07T02:30:18.990746+00:00 app[web.1]:     Arbiter(self).run()
2015-04-07T02:30:18.990823+00:00 app[web.1]:     self.manage_workers()
2015-04-07T02:30:19.728739+00:00 heroku[web.1]: Process exited with status 1
2015-04-07T02:30:19.750144+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-07T02:30:19.750381+00:00 heroku[web.1]: State changed from crashed to starting
2015-04-07T02:30:22.860260+00:00 heroku[web.1]: Starting process with command `gunicorn djangogirls.wsgi`
2015-04-07T02:30:24.130180+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [3] [INFO] Listening at: http://0.0.0.0:24389 (3)
2015-04-07T02:30:24.137056+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [9] [INFO] Booting worker with pid: 9
2015-04-07T02:30:24.170773+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.170770+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [10] [ERROR] Exception in worker process:
2015-04-07T02:30:24.170775+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.170777+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.130312+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [3] [INFO] Using worker: sync
2015-04-07T02:30:24.170780+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.170778+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.170791+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.170792+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.170783+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.170784+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.170786+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.170798+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.170793+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.170795+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.170796+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.170788+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.170789+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.170806+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.170807+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.170808+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.170799+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.170811+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.170802+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.170803+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.170804+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.170800+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.170781+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.176154+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 189, in run
2015-04-07T02:30:24.176159+00:00 app[web.1]:     Arbiter(self).run()
2015-04-07T02:30:24.176144+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.176162+00:00 app[web.1]:     self.manage_workers()
2015-04-07T02:30:24.176151+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2015-04-07T02:30:24.176168+00:00 app[web.1]:     time.sleep(0.1 * random.random())
2015-04-07T02:30:24.176153+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2015-04-07T02:30:24.176156+00:00 app[web.1]:     super(Application, self).run()
2015-04-07T02:30:24.170877+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [10] [INFO] Worker exiting (pid: 10)
2015-04-07T02:30:24.176163+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
2015-04-07T02:30:24.176148+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2015-04-07T02:30:24.176165+00:00 app[web.1]:     self.spawn_workers()
2015-04-07T02:30:24.176149+00:00 app[web.1]:     sys.exit(run())
2015-04-07T02:30:24.176166+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 541, in spawn_workers
2015-04-07T02:30:24.170813+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.176161+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 174, in run
2015-04-07T02:30:24.178515+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2015-04-07T02:30:24.170810+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.176158+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2015-04-07T02:30:24.178505+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2015-04-07T02:30:24.141236+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.176170+00:00 app[web.1]:     self.reap_workers()
2015-04-07T02:30:24.176169+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 214, in handle_chld
2015-04-07T02:30:24.176172+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
2015-04-07T02:30:24.141232+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.141237+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.141239+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.141254+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2015-04-07T02:30:24.141229+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.129374+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [3] [INFO] Starting gunicorn 19.3.0
2015-04-07T02:30:24.141223+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [9] [ERROR] Exception in worker process:
2015-04-07T02:30:24.141231+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.141246+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.141228+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.141248+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.141226+00:00 app[web.1]: Traceback (most recent call last):
2015-04-07T02:30:24.141251+00:00 app[web.1]:     worker.init_process()
2015-04-07T02:30:24.141234+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.141252+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
2015-04-07T02:30:24.141240+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.141249+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
2015-04-07T02:30:24.141242+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.141243+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.141244+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.141262+00:00 app[web.1]:     return util.import_app(self.app_uri)
2015-04-07T02:30:24.141256+00:00 app[web.1]:     self.callable = self.load()
2015-04-07T02:30:24.141259+00:00 app[web.1]:     return self.load_wsgiapp()
2015-04-07T02:30:24.141263+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
2015-04-07T02:30:24.141255+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-04-07T02:30:24.141258+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-04-07T02:30:24.141260+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-04-07T02:30:24.166744+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [10] [INFO] Booting worker with pid: 10
2015-04-07T02:30:24.141264+00:00 app[web.1]:     __import__(module)
2015-04-07T02:30:24.141266+00:00 app[web.1]: ImportError: No module named djangogirls.wsgi
2015-04-07T02:30:24.141324+00:00 app[web.1]: [2015-04-07 02:30:24 +0000] [9] [INFO] Worker exiting (pid: 9)
2015-04-07T02:30:24.956327+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-07T02:30:24.942505+00:00 heroku[web.1]: Process exited with status 1
2015-04-07T02:30:39.168025+00:00 heroku[api]: Scale to web=1 by paulzovighian@gmail.com
2015-04-07T02:30:45.176867+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=jtestblog.herokuapp.com request_id=457b2a51-1fc2-4f83-8316-c8fb0635c97b fwd="67.70.37.25" dyno= connect= service= status=503 bytes=
2015-04-07T02:30:48.582173+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=jtestblog.herokuapp.com request_id=137c668e-8d93-4c14-b98d-d1737adabf97 fwd="67.70.37.25" dyno= connect= service= status=503 bytes=
2015-04-07T02:30:48.976617+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/admin/" host=jtestblog.herokuapp.com request_id=8ad477b3-4348-4a90-b7bf-53791d7c5e02 fwd="67.70.37.25" dyno= connect= service= status=503 bytes=
2015-04-07T02:30:54.502759+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/admin/" host=jtestblog.herokuapp.com request_id=c074764e-4ac9-4205-8762-8073bf3cd7d6 fwd="67.70.37.25" dyno= connect= service= status=503 bytes=

这似乎是本教程中比较困难的阶段之一,我似乎无法弄清楚这个错误的确切含义...在此先感谢任何可以提供帮助的人,我真的很感激!

问题出在您的 Procfile 中。说明说要做:

web: gunicorn mysite.wsgi

但是您输入的是 "djangogirls" 而不是 "mysite"。正如您在评论中解释的那样,您的项目实际上称为 "mysite",而 "djangogirls" 只是包含文件夹的名称。

如果您在根目录中项目文件夹,那么您必须提供准确的路径,这样 gunicorn 才能更好地服务..:)

喜欢web: gunicorn --pythonpath app app.wsgi

了解更多信息pythonpath