2

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...
                                                             ^
user1778743
  • 333
  • 2
  • 7
  • 19
  • please provide the full traceback. Error clearly says your **django_session** table is missing. – dnit13 Sep 26 '16 at 15:03
  • @dnit13 i found the issue postgresql doesnt have "django_sessions" table while my sqlite database does any i can force postgre to create it? – user1778743 Sep 26 '16 at 15:06
  • 1
    `python manage.py migrate` should create it. – dnit13 Sep 26 '16 at 15:07
  • @dnit13 it tells me no migrations to apply when i make migrations – user1778743 Sep 26 '16 at 15:15
  • if its a new database, you can simply delete the database and recreate it. This should solve your problem – dnit13 Sep 26 '16 at 15:25
  • Did you try this https://stackoverflow.com/questions/26220689/programmingerror-relation-django-session-does-not-exist-error-after-installin ? – AlexKh Feb 04 '19 at 15:01
  • @dnit13 I'm facing the same issue. how did you fix this? – wizard Jun 18 '22 at 18:29
  • @wizard are you running migrations against a new db? I so .. just drop your db and recreate it and then run the `python manage.py migrate` – dnit13 Jun 22 '22 at 08:28
  • @dnit13 I did that having the same issue: it's weird everything working fine without gunicorn. when I run with gunicorn it is giving me an error. – wizard Jun 23 '22 at 12:28
  • @wizard maybe your database pointing to a different location while running with gunicorn. – dnit13 Jun 29 '22 at 05:59

1 Answers1

0

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

user1778743
  • 333
  • 2
  • 7
  • 19