Python ProgrammingError:安装 Psycopg2 后,关系“django_session”不存在错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26220689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ProgrammingError: relation "django_session" does not exist error after installing Psycopg2
提问by Alex Jolig
I started to develop a Django base web application. Everything were fine until I installed Psycopg2for my database which I created in PstgreSql. Now when I'm trying to open any page in my site, it throws ProgrammingError: relation "django_session" does not existerror.
我开始开发基于 Django 的 Web 应用程序。一切都很好,直到我安装Psycopg2了我在PstgreSql. 现在,当我尝试打开网站中的任何页面时,它会引发ProgrammingError: relation "django_session" does not exist错误。
Request Method: GET
Request URL: http://127.0.0.1:8000/login/
Django Version: 1.7
Exception Type: ProgrammingError
Exception Value:
relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
^
Exception Location: /home/alex/.virtualenvs/startDjango/local/lib/python2.7/site-packages/django/db/backends/utils.py in execute, line 65
Python Executable: /home/alex/.virtualenvs/startDjango/bin/python
This is my database setting in Setting.py
这是我的数据库设置 Setting.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myDB',
'USER': 'alex',
'PASSWORD': 'mypassword',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
I'm developing in virtualenvs
我在发展 virtualenvs
Any idea how to fix this? Thanks
知道如何解决这个问题吗?谢谢
采纳答案by falsetru
If you change the database, you should create database for the new database.
如果更改数据库,则应为新数据库创建数据库。
Use manage.py migratecommand. (or manage.py syncdbif you used it for old database).
使用manage.py migrate命令。(或者manage.py syncdb如果您将它用于旧数据库)。
回答by unlockme
You can alternatively migrate just the sessions app if you have already run migrate and still getting the error
如果您已经运行 migrate 并且仍然收到错误,您也可以只迁移会话应用程序
python manage.py migrate sessions

