Django hook with postgresql using psycopg2

I am trying to connect my site before using postgresql. I installed postgresql and psycopg2. In settings.py, I posted the following and then got an error after that. I should mention that I tested the site using mysql before trying to switch to postresql.

from Settings.py:

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'pdbt', 'USER': '', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '', } } 

Error:

 DatabaseError at /viewer/ relation "django_session" does not exist LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se... 
+4
source share
3 answers

Ok, I figured it out - I needed to run syncdb! Clap. In addition, I see that karthikr indicated the same thing. Thanks!

+1
source

And if someone uses newer versions of django , they should run this command:

 //for newer versions python manage.py migrate //for old versions python manage.py syncdb 
+2
source

If you see the above error message, it means that you have not created tables yet. To create tables, follow these steps:

  • Go to the directory where you have "manage.py"
  • Then execute 'python manage.py syncdb' and you will see the following: enter image description here
+1
source

Source: https://habr.com/ru/post/1487490/


All Articles