gpt4 book ai didi

python - ProgrammingError : relation "django_session" does not exist

转载 作者:行者123 更新时间:2023-11-28 21:36:57 25 4
gpt4 key购买 nike

将我的数据库从sqlite更改为postgresql后,出现此错误。我已经进行了所有设置更改:

这是我的设置:

DATABASES = {
'default': {
'ENGINE': "django.db.backends.postgresql_psycopg2",
'NAME': "postr1",
'USER': "zorgan",
'PASSWORD': config('DB_PASSWORD'),
'HOST': "localhost",
'PORT': '',
}
}

以及成功执行 makemigrationsmigrations。这样我就可以成功启动本地服务器了:
System check identified no issues (0 silenced).
May 15, 2018 - 08:59:39
Django version 1.11.8, using settings 'draft1.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

但是,当我转到该站点时,它将返回此错误:
ProgrammingError at /news/
relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...

知道是什么问题吗?

最佳答案

尝试将fake migrate设置为零。

您的迁移历史记录表明sessions表已经完成,但是您没有真实的表。

所以下面

python manage.py migrate --fake sessions zero
# then your sessions migrate will be
python manage.py showmigrations
sessions
[ ] 0001_initial
# then migrate with --fake-initial again
python manage.py migrate --fake-initial

然后再试一次。

关于python - ProgrammingError : relation "django_session" does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50346326/

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