Django管理员给内部服务器错误500

时间:2015-03-05 17:16:27

标签: django django-admin

我的django和python知识不是很深。我按照Django教程(1.7),然后为某人创建了一个应用程序,通过django管理员更新人员列表。我让它在本地工作,它在我的登台服务器上也能正常工作。

在制作时,网站正常运行,我可以进入管理登录页面。但是当我登录时,我收到500内部服务器错误。我花了大约两天的时间试图调试它。

Apache错误日志显示" [Errno 111]拒绝连接"但很多谷歌搜索文本已经发现我还没有用。

基于我在这里找到的一些相关对话,他们似乎专注于使用django发送电子邮件(我不是)。

我认为我已正确配置了允许的主机,因为我可以看到非管理员网站。

我已经比较了登台服务器和生产服务器之间的apache配置和文件权限,它们似乎都是相同的。

我们非常感谢您提供的任何帮助。谢谢。

error.log中

[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664] mod_wsgi (pid=26646): Exception occurred processing WSGI script '/home/admin/dj-1.7/accountedge/trunk/accountedge/accountedge/wsgi.py'., referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664] Traceback (most recent call last):, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     response = self.get_response(request), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 199, in get_response, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info()), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 231, in handle_uncaught_exception, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     'request': request, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     self._log(ERROR, msg, args, **kwargs), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/logging/__init__.py", line 1271, in _log, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     self.handle(record), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/logging/__init__.py", line 1281, in handle, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     self.callHandlers(record), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/logging/__init__.py", line 1321, in callHandlers, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     hdlr.handle(record), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/logging/__init__.py", line 749, in handle, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     self.emit(record), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/utils/log.py", line 132, in emit, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     connection=self.connection()), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/core/mail/__init__.py", line 98, in mail_admins, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     mail.send(fail_silently=fail_silently), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/core/mail/message.py", line 286, in send, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     return self.get_connection(fail_silently).send_messages([self]), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 92, in send_messages, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     new_conn_created = self.open(), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/home/admin/dj-1.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 50, in open, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     self.connection = connection_class(self.host, self.port, **connection_params), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/smtplib.py", line 251, in __init__, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     (code, msg) = self.connect(host, port), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/smtplib.py", line 311, in connect, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     self.sock = self._get_socket(host, port, self.timeout), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/smtplib.py", line 286, in _get_socket, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     return socket.create_connection((host, port), timeout), referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]   File "/usr/lib/python2.7/socket.py", line 571, in create_connection, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664]     raise err, referer: ***.com/admin/login/?next=/admin/
[wsgi:error] [pid 26646:tid 140557972109056] [client xx.xx.xxx.xx:57664] error: [Errno 111] Connection refused, referer: ***.com/admin/login/?next=/admin/

settings.py

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from os import path
import socket
from os.path import dirname
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ROOT_PATH = os.path.dirname(__file__)
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'x'

# SECURITY WARNING: don't run with debug turned on in production!
if socket.gethostname().startswith('x'):
    DEBUG = TEMPLATE_DEBUG = True
else:
    DEBUG = TEMPLATE_DEBUG = False

ALLOWED_HOSTS = [
    '.accountedge.com',
    'accountedge.com',
    'localhost',
    '162.209.1.124',
    '162.209.4.135',
]


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'geoip',
    'localflavor',
    'partners',
)

MIDDLEWARE_CLASSES = (
    '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 = 'accountedge.urls'

WSGI_APPLICATION = 'accountedge.wsgi.application'

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'accountedge/templates'),
)

# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

ADMINS = (
    ('ed', 'x'),
)

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'America/New_York'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'

STATIC_ROOT = path.join(PROJECT_ROOT, 'static-root/')

## local
if socket.gethostname().startswith('x'):
    STATIC_URL = '/static/'
## staging: rackspace
elif socket.gethostname() == 'rerun-mktg':
    STATIC_URL = 'http://x/accountedge/staging/rackspace/static/'
## PRODUCTION
else:
    STATIC_URL = 'http://x/accountedge/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    ('', path.join(PROJECT_ROOT,'static')),
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.contrib.messages.context_processors.messages',
    'geoip.context.maxmind',
)

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.load_template_source',
)

1 个答案:

答案 0 :(得分:0)

您似乎在某个地方使用send_mail()并且您尚未指定任何邮件设置。有关详细信息,请参阅django docs