[英]django+heroku+postgres error in createsuperuser command,its giving an error “psycopg2.errors.UndefinedTable: relation ”users_profile“ does not exist”
[英]cannot migrate from Django sqlite3 to postgres, getting "psycopg2.errors.UndefinedTable: relation doest not exist" error
我正在嘗試將 sqlite3 數據庫從我的 Django 應用程序遷移到 postgres 數據庫。 我已經嘗試了所有的教程,但是當我嘗試運行“python manage.py migrate --run-syncdb”或“python manage.py migrate”時似乎無法解決這個錯誤。 我也安裝了 psycopg2。
設置.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db',
'USER': 'postgres',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '5432',
}
}
錯誤是“psycopg2.errors.UndefinedTable: 關系“users_postcategory”不存在 LINE 1: ...ategory"."name", "users_postcategory"."name" FROM "users_pos..."
嘗試添加public.
con = psycopg2.connect(
host = 'localhost',
user = 'postgres',
password = '2356216',
database = 'excursion'
)
cursor = con.cursor()
sql = ''
if lang == 'ru':
sql = f"""SELECT ID, Name_ru, Description_ru, Photo, Point_width, Point_longitude, Link
FROM memorable
JOIN communication ON public.communication.memorableid = public.memorable.id
WHERE communication.RouteID = {ExcID}"""
if lang == 'en':
sql = f"""SELECT ID, Name, Description, Photo, Point_width, Point_longitude, Link
FROM memorable
JOIN communication ON communication.memorableid = memorable.id
WHERE communication.RouteID = {ExcID}"""
cursor.execute(sql)
result = cursor.fetchall()
return result
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.