【发布时间】:2021-07-22 00:20:06
【问题描述】:
对于使用 heroku 提供的业余爱好免费 postgres 版本部署 heroku django 应用程序,有人有任何提示吗?如果我在 django 构建过程中没有执行python manage.py migrate,那么当我在本地测试时,回溯中的这个错误几乎看起来相似。
也是 django、heroku 和 postgress 的新手,因此提示非常有帮助。这些是我使用 heroku 管道进行部署的步骤:
git push heroku master
heroku ps:scale web=1
heroku open
这是我尝试查看网页时通过 heroku 日志返回的跟踪:
2021-04-28T15:42:39.226298+00:00 heroku[web.1]: State changed from crashed to starting
2021-04-28T15:42:46.842959+00:00 heroku[web.1]: Starting process with command `gunicorn mysite.wsgi --log-file -`
2021-04-28T15:42:50.000000+00:00 app[api]: Build succeeded
2021-04-28T15:42:50.613040+00:00 app[web.1]: [2021-04-28 15:42:50 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-04-28T15:42:50.614019+00:00 app[web.1]: [2021-04-28 15:42:50 +0000] [4] [INFO] Listening at: http://0.0.0.0:38735 (4)
2021-04-28T15:42:50.614239+00:00 app[web.1]: [2021-04-28 15:42:50 +0000] [4] [INFO] Using worker: sync
2021-04-28T15:42:50.624501+00:00 app[web.1]: [2021-04-28 15:42:50 +0000] [9] [INFO] Booting worker with pid: 9
2021-04-28T15:42:50.648659+00:00 app[web.1]: [2021-04-28 15:42:50 +0000] [10] [INFO] Booting worker with pid: 10
2021-04-28T15:42:51.320006+00:00 heroku[web.1]: State changed from starting to up
2021-04-28T15:43:08.733160+00:00 app[web.1]: Internal Server Error: /
2021-04-28T15:43:08.733171+00:00 app[web.1]: Traceback (most recent call last):
2021-04-28T15:43:08.733172+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
2021-04-28T15:43:08.733173+00:00 app[web.1]: return self.cursor.execute(sql, params)
2021-04-28T15:43:08.733174+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "blog_post" does not exist
2021-04-28T15:43:08.733174+00:00 app[web.1]: LINE 1: SELECT COUNT(*) AS "__count" FROM "blog_post" WHERE "blog_po...
2021-04-28T15:43:08.733175+00:00 app[web.1]: ^
更新,正如第一条评论中漂亮地提到的那样,你做了教程吗?我在部署到 heroku the database section heroku run python manage.py migrate 时错过了这个。完成整个教程,确保它先在本地运行!
【问题讨论】:
-
您是否尝试过遵循Getting Started on Heroku with Python 教程?
-
谢谢我检查了...
-
感谢这里的提示我会发布更新....
标签: python django postgresql heroku