gpt4 book ai didi

django - 关系 "django_session"不存在

转载 作者:行者123 更新时间:2023-12-02 03:33:40 26 4
gpt4 key购买 nike

现在我是 Heroku 的新手,并尝试在 Heroku 上部署我的 Django 应用程序。只需按照说明操作就成功了,我可以在 heroku 中进行测试。但是当我将本地数据库从 sqlite 更改为 postgres 后,由于错误,我无法进一步操作。可能和DB有关。我的应用程序在本地基地仍然运行良好,但在 Heroku 中却不行,而我将所有应用程序都推送到了 Heroku。

基础.py

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
db_from_env = dj_database_url.config()
DATABASES['default'].update(db_from_env)

Debug模式下的错误消息

ProgrammingError at /
relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
^
Request Method: GET
Request URL: https://happybom.herokuapp.com/
Django Version: 2.0.4
Exception Type: ProgrammingError
Exception Value:
relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
^
Exception Location: /app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py in _execute, line 85
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.6.4
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python36.zip',
'/app/.heroku/python/lib/python3.6',
'/app/.heroku/python/lib/python3.6/lib-dynload',
'/app/.heroku/python/lib/python3.6/site-packages']

heroku 日志

2018-06-27T16:19:46.500148+00:00 app[api]: Starting process with command `bash` by user <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d6a2aeaeae96b1bbb7bfbaf8b5b9bb" rel="noreferrer noopener nofollow">[email protected]</a>
2018-06-27T16:19:54.976946+00:00 heroku[run.8196]: Awaiting client
2018-06-27T16:19:55.035413+00:00 heroku[run.8196]: Starting process with command `bash`
2018-06-27T16:19:55.078847+00:00 heroku[run.8196]: State changed from starting to up
2018-06-27T16:20:17.457935+00:00 heroku[run.8196]: Client connection closed. Sending SIGHUP to all processes
2018-06-27T16:20:17.995204+00:00 heroku[run.8196]: Process exited with status 129
2018-06-27T16:20:18.015161+00:00 heroku[run.8196]: State changed from up to complete
2018-06-27T16:21:37.988762+00:00 app[api]: Starting process with command `bash` by user <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="512529292911363c30383d7f323e3c" rel="noreferrer noopener nofollow">[email protected]</a>
2018-06-27T16:21:49.979009+00:00 heroku[run.2682]: Awaiting client
2018-06-27T16:21:50.038333+00:00 heroku[run.2682]: Starting process with command `bash`
2018-06-27T16:21:50.171144+00:00 heroku[run.2682]: State changed from starting to up
2018-06-27T16:52:53.428934+00:00 heroku[run.2682]: Client connection closed. Sending SIGHUP to all processes
2018-06-27T16:52:53.967773+00:00 heroku[run.2682]: Process exited with status 129
2018-06-27T16:52:54.005827+00:00 heroku[run.2682]: State changed from up to complete
2018-06-27T17:02:52.720107+00:00 heroku[web.1]: Unidling
2018-06-27T17:02:52.720404+00:00 heroku[web.1]: State changed from down to starting
2018-06-27T17:02:57.851621+00:00 heroku[web.1]: Starting process with command `gunicorn estimate.wsgi`
2018-06-27T17:03:00.563084+00:00 app[web.1]: [2018-06-27 17:03:00 +0000] [4] [INFO] Starting gunicorn 19.8.0
2018-06-27T17:03:00.563690+00:00 app[web.1]: [2018-06-27 17:03:00 +0000] [4] [INFO] Listening at: http://0.0.0.0:35753 (4)
2018-06-27T17:03:00.567579+00:00 app[web.1]: [2018-06-27 17:03:00 +0000] [8] [INFO] Booting worker with pid: 8
2018-06-27T17:03:00.563791+00:00 app[web.1]: [2018-06-27 17:03:00 +0000] [4] [INFO] Using worker: sync
2018-06-27T17:03:00.587739+00:00 app[web.1]: [2018-06-27 17:03:00 +0000] [9] [INFO] Booting worker with pid: 9
2018-06-27T17:03:02.002190+00:00 heroku[web.1]: State changed from starting to up
2018-06-27T17:03:02.895543+00:00 app[web.1]: Internal Server Error: /
2018-06-27T17:03:02.895572+00:00 app[web.1]: Traceback (most recent call last):
2018-06-27T17:03:02.895573+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py", line 191, in _get_session
2018-06-27T17:03:02.895575+00:00 app[web.1]: return self._session_cache
2018-06-27T17:03:02.895576+00:00 app[web.1]: AttributeError: 'SessionStore' object has no attribute '_session_cache'
2018-06-27T17:03:02.895578+00:00 app[web.1]:
2018-06-27T17:03:02.895580+00:00 app[web.1]:
2018-06-27T17:03:02.895579+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2018-06-27T17:03:02.895582+00:00 app[web.1]: Traceback (most recent call last):
2018-06-27T17:03:02.895583+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
2018-06-27T17:03:02.895584+00:00 app[web.1]: return self.cursor.execute(sql, params)
2018-06-27T17:03:02.895585+00:00 app[web.1]: psycopg2.ProgrammingError: relation "django_session" does not exist
2018-06-27T17:03:02.895586+00:00 app[web.1]: LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
2018-06-27T17:03:02.895588+00:00 app[web.1]: ^
2018-06-27T17:03:02.895589+00:00 app[web.1]:
2018-06-27T17:03:02.895590+00:00 app[web.1]:
2018-06-27T17:03:02.895591+00:00 app[web.1]: The above exception was the direct cause of the following exception:

heroku 数据库状态

heroku pg:信息

=== HEROKU_POSTGRESQL_COPPER_URL, DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 10.4
Created: 2018-06-26 03:07 UTC
Data Size: 7.6 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: Off
Add-on: postgresql-globular-10516

=== HEROKU_POSTGRESQL_CHARCOAL_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 10.4
Created: 2018-04-28 23:05 UTC
Data Size: 7.9 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: Off
Add-on: postgresql-shaped-32846

heroku pg:diagnose --app happybom

Report 4264cbec-925d-40d3-ad75-45bee458d28e for happybom::DATABASE_URL
available for one month after creation on 2018-06-27T17:38:29.568775+00:00

GREEN: Connection Count
GREEN: Long Queries
GREEN: Idle in Transaction
GREEN: Indexes
GREEN: Bloat
GREEN: Hit Rate
GREEN: Blocking Queries
GREEN: Sequences
SKIPPED: Load
Error Load check not supported on this plan

最佳答案

您在 Heroku 上运行过迁移吗?

heroku run python manage.py migrate

关于django - 关系 "django_session"不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51068671/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com