将postgresql数据库与Django一起用于heroku

2024-05-19 20:27:49 发布

您现在位置:Python中文网/ 问答频道 /正文

使用heroku应用所有迁移后,运行python manage.py migrate。 它给出了这个错误。 我换成了postgresql。但迁移仍然只应用于sqlite3

OperationalError at /
no such table: shastri_occasion
Request Method: GET
Request URL:    https://bdsharma.herokuapp.com/
Django Version: 3.1.1
Exception Type: OperationalError
Exception Value:    
no such table: shastri_occasion
Exception Location: /app/.heroku/python/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py, line 413, in execute
Python Executable:  /app/.heroku/python/bin/python
Python Version: 3.6.12
Python Path:    
['/app/.heroku/python/bin',
 '/app',
 '/app/.heroku/python/lib/python36.zip',
 '/app/.heroku/python/lib/python3.6',
 '/app/.heroku/python/lib/python3.6/lib-dynload',
 '/app/.heroku/python/lib/python3.6/site-packages']
Server time:    Fri, 11 Sep 2020 09:34:29 +0000

我换成了postgresql。但迁移仍然只应用于sqlite3。 这是my setting.py数据库设置:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'ddbp7me1o4bf',
        'USER' :'iwdvmaevgph',
        'PASSWORD' : '****************************8',
        'HOST' : '*****************8',
        'PORT' : '5432',

    }
}

Tags: nopyappherokuversionrequestpostgresqllib
1条回答
网友
1楼 · 发布于 2024-05-19 20:27:49

您可以这样配置数据库设置

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

相关问题 更多 >