djangopostgresqldjango-database

django.db.utils.ProgrammingError: relation "django_session" does not exist line 1


I am using Django 1.8 python 3.5

and recently completed one app which was using sqlite and everything was fine

now i created a new app that i need to connect to a existing database on postgre ( in the same project folder )

i did the database inspectdb and got the models generated from it.

i didnt know how to setup two databases so i commented out the old "default" database and wrote my settings for the new one. but when i try and go on the homepage of the app i get a server error and cmd.exe gives me this

django.db.utils.ProgrammingError" relation "django_session" does not exist LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se..
                                                                                                                                        ^

now i saw online i needed to migrate ( which i did )

and i saw as well i need to syncdb ( which i did )

but nothing worked

but while trying to figure out i saw this way at the top of all the tracebacks

AttributeError: 'SessionStore' object has no  attribute '_session_cahce'




(landregtry1) C:\Sites\Landregistry>python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
September 26, 2016 - 11:06:36
Django version 1.8, using settings 'Landregistry.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Traceback (most recent call last):
  File "C:\Users\yfevrier\Envs\landregtry1\lib\site-packages\django\contrib\sess
ions\backends\base.py", line 176, in _get_session
    return self._session_cache
AttributeError: 'SessionStore' object has no attribute '_session_cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\yfevrier\Envs\landregtry1\lib\site-packages\django\db\backends\
utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
                                                             ^

Solution

  • python3 manage.py migrate --sync-db ( i think i am answering these questions years later)