I’m hosting two websites on ubuntu server and both having postgresql, the first one is working prefect but the second give me this error
no such table: wagtailcore_site Request Method: GET
Django Version: 2.2.10 Exception
Type: OperationalError Exception Value: no such table:
wagtailcore_site Exception
Location: /home/project2/.venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py
in execute, line 383 Python
Executable: /home/project2/.venv/bin/python3.7m Python Version: 3.7.3
database settings for first website:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'project_one', 'USER': 'project_one', 'PASSWORD': '123', 'HOST': '127.0.0.1', 'PORT': '', } }
database settings for second website:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'project_two', 'USER': 'project_two', 'PASSWORD': '123', 'HOST': '127.0.0.1', 'PORT': '', } }
from the error it seems that django try to run sqllite instead of postgresql, I dont know why !
Notes:
python manage.py migrate
command working without any problem whith the second database.SQL lite is working, the problem only with postgresql in the second project.
I’m using nginx and gunicorn.
I think the problem maybe with the HOST
and PORT
settings in both settings maybe they conflicting each other? ( I try change the port and host also but didn’t solve it)
thanks.
Advertisement
Answer
My bad, I have two gunicorn files for both websites and I was restarting gunicorn for first websites not the second one.
Which mean there is no errors in the code above.. The problem only in restarting gunicorn.