在heroku上部署Django应用程序时出现应用程序错误

时间:2020-06-26 19:19:06

标签: django heroku

我的Django应用程序在本地运行良好,但在heroku上部署时出现此错误:

应用程序错误 应用程序中发生错误,无法提供您的页面。如果您是应用程序所有者,请检查日志以获取详细信息。您可以使用以下命令从Heroku CLI中进行操作

一些网上解决方案说也可以运行:

heroku run python manage.py createsuperuser

但这会导致错误:

django.db.utils.ProgrammingError: relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...

也:

You have 26 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): Finance, admin, auth, checklist, contenttypes, sessions, tasks.
Run 'python manage.py migrate' to apply them.

但是我已经在命令提示符下多次运行了以下行。

> python manage.py makemigrations 
> python manage.py migrate

我也将这些行添加到settings.py中,如其他一些解决方案所述:

import django_heroku
django_heroku.settings(locals())

我还尝试删除该应用并重新设置,但错误仍然存​​在。 还尝试删除所有迁移并进行新的迁移,但错误仍然存​​在。 同样要注意的是,即使最初我仍然可以正常运行2秒钟,然后我甚至都无法访问管理员登录页面。

我还附加了以下日志文​​件:

2020-06-26T18:45:17.912130+00:00 app[api]: Release v1 created by user shivam.sarda@workamp.co
2020-06-26T18:45:17.912130+00:00 app[api]: Initial release by user shivam.sarda@workamp.co
2020-06-26T18:45:18.027404+00:00 app[api]: Enable Logplex by user shivam.sarda@workamp.co
2020-06-26T18:45:18.027404+00:00 app[api]: Release v2 created by user shivam.sarda@workamp.co
2020-06-26T18:45:38.089573+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=workamp.herokuapp.com request_id=025fd57e-8a24-4d55-83a1-bda87494d7af fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:45:38.593100+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=workamp.herokuapp.com request_id=4e8f013b-2d1e-4e35-9395-6cf84bcefa52 fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:47:52.000000+00:00 app[api]: Build started by user shivam.sarda@workamp.co
2020-06-26T18:48:16.453424+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=workamp.herokuapp.com request_id=f6720d5d-83b9-4bb8-9d06-3147002c0f14 fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:48:16.820355+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=workamp.herokuapp.com request_id=555a27f5-6fb8-468c-b3c0-f6ed9addee83 fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:48:21.484767+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/admin" host=workamp.herokuapp.com request_id=8c540e59-b597-4526-a236-ab10b9b384f2 fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:48:21.871906+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=workamp.herokuapp.com request_id=8bd54546-7fe6-49b2-b704-259101829669 fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:48:27.401632+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/admin" host=workamp.herokuapp.com request_id=de2a98ff-6bba-4751-938b-9177df48ffbc fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:48:27.764216+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=workamp.herokuapp.com request_id=edc10e97-22f4-4db3-b665-074d86ae041f fwd="61.0.152.114" dyno= connect= service= status=502 bytes= protocol=http
2020-06-26T18:49:47.989479+00:00 app[api]: Attach DATABASE (@ref:postgresql-graceful-72554) by user shivam.sarda@workamp.co
2020-06-26T18:49:47.989479+00:00 app[api]: Running release v3 commands by user shivam.sarda@workamp.co
2020-06-26T18:49:47.999116+00:00 app[api]: @ref:postgresql-graceful-72554 completed provisioning, setting DATABASE_URL. by user shivam.sarda@workamp.co
2020-06-26T18:49:47.999116+00:00 app[api]: Release v4 created by user shivam.sarda@workamp.co
2020-06-26T18:49:48.229248+00:00 app[api]: Deploy 94879a30 by user shivam.sarda@workamp.co
2020-06-26T18:49:48.229248+00:00 app[api]: Release v5 created by user shivam.sarda@workamp.co
2020-06-26T18:50:13.000000+00:00 app[api]: Build succeeded
2020-06-26T18:52:45.849109+00:00 app[api]: Starting process with command `python mnage.py createsuperuser` by user shivam.sarda@workamp.co
2020-06-26T18:52:57.950366+00:00 heroku[run.8772]: State changed from starting to up
2020-06-26T18:52:58.180376+00:00 heroku[run.8772]: Awaiting client
2020-06-26T18:52:58.218485+00:00 heroku[run.8772]: Starting process with command `python mnage.py createsuperuser`
2020-06-26T18:53:02.805473+00:00 heroku[run.8772]: Process exited with status 2
2020-06-26T18:53:02.859662+00:00 heroku[run.8772]: State changed from up to complete
2020-06-26T18:53:10.575518+00:00 app[api]: Starting process with command `python manage.py createsuperuser` by user shivam.sarda@workamp.co
2020-06-26T18:53:21.163902+00:00 heroku[run.7938]: State changed from starting to up
2020-06-26T18:53:21.176279+00:00 heroku[run.7938]: Awaiting client
2020-06-26T18:53:21.227318+00:00 heroku[run.7938]: Starting process with command `python manage.py createsuperuser`
2020-06-26T18:53:26.576213+00:00 heroku[run.7938]: Process exited with status 1
2020-06-26T18:53:26.613259+00:00 heroku[run.7938]: State changed from up to complete
2020-06-26T18:54:30.833570+00:00 app[api]: Starting process with command `python manage.py createsuperuser` by user shivam.sarda@workamp.co
2020-06-26T18:54:44.903222+00:00 heroku[run.9000]: State changed from starting to up
2020-06-26T18:54:45.163642+00:00 heroku[run.9000]: Awaiting client
2020-06-26T18:54:45.212756+00:00 heroku[run.9000]: Starting process with command `python manage.py createsuperuser`
2020-06-26T18:54:51.269365+00:00 heroku[run.9000]: Process exited with status 1
2020-06-26T18:54:51.303225+00:00 heroku[run.9000]: State changed from up to complete
2020-06-26T18:56:10.723168+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/admin" host=workamp.herokuapp.com request_id=1439c6f7-fcc1-4e07-bc5a-6510948e3e60 fwd="61.0.152.114" dyno= connect= service= status=503 bytes= protocol=http
2020-06-26T18:56:11.367850+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=workamp.herokuapp.com request_id=8723c392-013b-451e-be18-8cec27375f72 fwd="61.0.152.114" dyno= connect= service= status=503 bytes= protocol=http
2020-06-26T18:58:37.791124+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/admin" host=workamp.herokuapp.com request_id=fd1b6519-922a-4446-a8f8-7d4cc16953b7 fwd="61.0.152.114" dyno= connect= service= status=503 bytes= protocol=http
2020-06-26T18:58:38.358495+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=workamp.herokuapp.com request_id=5dc586e8-8cb9-4172-a949-819eddcf0815 fwd="61.0.152.114" dyno= connect= service= status=503 bytes= protocol=http
2020-06-26T18:59:36.034719+00:00 app[api]: Starting process with command `python manage.py runserver` by user shivam.sarda@workamp.co
2020-06-26T18:59:46.262281+00:00 heroku[run.1465]: Awaiting client
2020-06-26T18:59:46.289032+00:00 heroku[run.1465]: Starting process with command `python manage.py runserver`
2020-06-26T18:59:46.306117+00:00 heroku[run.1465]: State changed from starting to up
2020-06-26T19:00:12.547296+00:00 heroku[run.1465]: Process exited with status 0
2020-06-26T19:00:12.578053+00:00 heroku[run.1465]: State changed from up to complete
2020-06-26T19:03:21.985107+00:00 app[api]: Starting process with command `python manage.py createsuperuser` by user shivam.sarda@workamp.co
2020-06-26T19:03:36.839804+00:00 heroku[run.4525]: State changed from starting to up
2020-06-26T19:03:37.525536+00:00 heroku[run.4525]: Awaiting client
2020-06-26T19:03:37.582336+00:00 heroku[run.4525]: Starting process with command `python manage.py createsuperuser`
2020-06-26T19:03:45.362388+00:00 heroku[run.4525]: Process exited with status 1
2020-06-26T19:03:45.402386+00:00 heroku[run.4525]: State changed from up to complete
2020-06-26T19:03:55.830080+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/admin" host=workamp.herokuapp.com request_id=6b69664b-21de-4755-9191-0d6f6c79f4c9 fwd="61.0.152.114" dyno= connect= service= status=503 bytes= protocol=http
2020-06-26T19:03:56.513662+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=workamp.herokuapp.com request_id=1abcee5e-dfb3-41be-9c0b-057c15de5bc9 fwd="61.0.152.114" dyno= connect= service= status=503 bytes= protocol=http
                                                         ^

1 个答案:

答案 0 :(得分:0)

没有任何Web进程在运行,这意味着您尚未添加Procfile。 您的项目应有一个名为Procfile的文件,其内容应类似于

web: gunicorn project_name.wsgi,其中 project_name是您的Django项目的名称。有关更多信息,请查看No web processes running Django in heroku