因此,我已经使用AWS EC2部署了我的项目。我也试图在本地服务器上运行该应用程序以进行测试。但随后出现以下错误。
Traceback (most recent call last):
File "C:\Users\user\Envs\venv\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
self.connect()
File "C:\Users\user\Envs\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\user\Envs\venv\lib\site-packages\django\db\backends\base\base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\user\Envs\venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\user\Envs\venv\lib\site-packages\django\db\backends\postgresql\base.py", line 185, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\user\Envs\venv\lib\site-packages\psycopg2\__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError
我在settings.py
import os
from .local_settings import PG_HOST
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME' : 'myDB',
'USER' : 'Manager',
'PASSWORD' : '###password###',
'HOST' : PG_HOST,
'PORT' : '',
}
}
这在local_settings.py
中。 (未在AWS服务器中使用)
PG_HOST = ''
您认为错在哪里?预先非常感谢。