ProgrammingError:关系“ django_session”;不存在 [英] ProgrammingError: relation "django_session" does not exist

查看:66
本文介绍了ProgrammingError:关系“ django_session”;不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Got this error after changing my database from sqlite to postgresql. I've made all my settings changes:

这是我的设置:

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

以及执行 makemigrations 迁移都成功。这样我就可以成功启动本地服务器:

as well as performing makemigrations and migrations which were all successful. So I'm able to succesfully start my local server:

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.

但是当我转到网站时,它会返回此错误:

however when I go to the site it returns this error:

ProgrammingError at /news/
relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...

你知道是什么问题吗?

推荐答案

尝试将假迁移设为零。

您的迁移历史记录显示已经创建了 sessions 表,但是您没有真实的表。

Your migration history shows that sessions table was already made, but you don't have real table.

所以下面是

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

然后重试。

这篇关于ProgrammingError:关系“ django_session”;不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆