问题描述
我开始开发Django基本网络应用程序。一切都很好,直到我为在 PstgreSql
中创建的数据库安装 Psycopg2
为止。现在,当我尝试打开网站中的任何页面时,它引发 ProgrammingError:关系 django_session不存在
错误。
I started to develop a Django base web application. Everything were fine until I installed Psycopg2
for 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 exist
error.
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
这是我在 Setting.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myDB',
'USER': 'alex',
'PASSWORD': 'mypassword',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
我在 virtualenvs
有什么办法解决吗?
谢谢
Any idea how to fix this?Thanks
推荐答案
如果更改数据库,则应为新数据库创建数据库。
If you change the database, you should create database for the new database.
使用命令。 (或如果您将其用于旧数据库)。
Use manage.py migrate
command. (or manage.py syncdb
if you used it for old database).
这篇关于ProgrammingError:关系“ django_session”;安装Psycopg2后不存在错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!