更新时间:2023-01-22 10:14:48
好的,我找到了解决方案:
我在 settings.py 文件中替换了此代码:
I replaced this code in my settings.py file:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myDB',
'USER': 'loicq',
'PASSWORD': '*********',
'HOST': 'localhost',
'PORT': '',
}
}
有了这个:
DATABASES = {'default': dj_database_url.config(default='postgres://YOURUSER:YOURPASSWORD@YOURHOST:5432/YOURDATABASENAME')}
使用 pip 安装 dj-database-url:
Installed dj-database-url with pip:
pip install dj_database_url
现在它完美地工作了!