ProgrammingError: relation “django_session” does not exist error after installing Psycopg2

ぐ巨炮叔叔 提交于 2019-12-03 14:29:39

问题


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

This is my database setting in 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

Any idea how to fix this? Thanks


回答1:


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).




回答2:


You can alternatively migrate just the sessions app if you have already run migrate and still getting the error

python manage.py migrate sessions


来源:https://stackoverflow.com/questions/26220689/programmingerror-relation-django-session-does-not-exist-error-after-installin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!