4
当我运行python manage.py执行syncdb,我得到这个错误:Django的PostgreSQL的执行syncdb错误
OperationalError: could not translate host name "localhost" to address: nodename nor servname provided, or not known
我的settings.py文件看起来是这样的:
if "IS_STAGING" in os.environ or "IS_PRODUCTION" in os.environ:
import dj_database_url
DATABASES = {'default':dj_database_url.config(default='postgres://localhost')}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'test', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': 'test',
'PASSWORD': 'test',
'HOST': 'localhost', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
}
localhost是在/ etc/hosts中定义的吗? –
'nslookup localhost'在您的机器中返回什么? –
你试着把127.0.0.1放在空白处还是留空? –