我正在使用 django 1.9,gunicorn,nginx和postgres 作为我网站的数据库。我的网站已启动并正在运行,但当我尝试以管理员身份登录 或用户时,我在网页和终端上获得服务器错误500 我得到“ 是在主机139.59.45.246上运行的服务器,并在端口5432上接受tcp / ip连接“。
我认为 postgres.conf 和 pg_hba.conf 可能存在问题。但是 pg_hba.conf 中有 2个主机...一个用于IPv4,一个用于IPv6 。
我无法弄清楚如何编辑pg_hba.conf。请使用上面的IP来解释。
还有一件事可以解决问题,还是我可能需要做点其他事情?
这是我的settings.py -
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '^4z+c_2^di81mt7sj@e8c&_b%###############'
DEBUG = False
ALLOWED_HOSTS = ['irenovate.in', '139.59.45.246']
INSTALLED_APPS = [
# django apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# my apps
'website',
'accounts',
# third party apps
'crispy_forms',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'irenovate.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'irenovate.wsgi.application'
# Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '########',
'USER': '########',
'PASSWORD': '........',
'HOST': '139.59.45.246',
'PORT': '',
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env", "static")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static_in_project", "our_static"),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env", "media_root")
CRISPY_TEMPLATE_PACK = 'bootstrap3'