[英]Server error 500 when deploy django to Heroku
I got following server error 500 when deploying django app to heroku. 将django应用部署到heroku时出现服务器错误500。 I have worked on this problem for 2 days to fix, but have no idea to solve the problems.
我已经解决了2天,但是不知道要解决什么问题。 I assume djangorestframework cause this problems because it has favicon.ico which leads "GET /favicon.ico HTTP/1.1" 404 77" but no idea.
我认为djangorestframework会导致此问题,因为它具有favicon.ico,导致“ GET /favicon.ico HTTP / 1.1” 404 77“,但不知道。
Does anyone detect issues? 有没有人发现问题? Thank you for your support in advance!!
谢谢您的提前支持!
2019-07-23T12:03:44.622777+00:00 app[api]: Release v23 created by user atnihs-do-21@hotmail.co.jp
2019-07-23T12:03:51.865737+00:00 heroku[web.1]: Starting process with command `gunicorn alumate.wsgi --log-file -`
2019-07-23T12:03:55.314454+00:00 heroku[web.1]: State changed from starting to up
2019-07-23T12:03:55.130912+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-07-23T12:03:55.132168+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [4] [INFO] Listening at: http://0.0.0.0:20191 (4)
2019-07-23T12:03:55.132311+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [4] [INFO] Using worker: sync
2019-07-23T12:03:55.138103+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [10] [INFO] Booting worker with pid: 10
2019-07-23T12:03:55.150027+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [11] [INFO] Booting worker with pid: 11
2019-07-23T12:03:55.000000+00:00 app[api]: Build succeeded
2019-07-23T12:04:30.649490+00:00 heroku[router]: at=info method=GET path="/" host=alumate.herokuapp.com request_id=0f1e339a-08fc-4b93-9c1b-1db28b675f76 fwd="210.150.77.215" dyno=web.1 connect=1ms service=835ms status=500 bytes=234 protocol=https
2019-07-23T12:04:30.649933+00:00 app[web.1]: 10.99.197.226 - - [23/Jul/2019:12:04:30 +0000] "GET / HTTP/1.1" 500 27 "https://dashboard.heroku.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
2019-07-23T12:04:31.116073+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=alumate.herokuapp.com request_id=381749d5-0137-4017-bd1b-8bb8cb6feef1 fwd="210.150.77.215" dyno=web.1 connect=0ms service=186ms status=404 bytes=258 protocol=https
2019-07-23T12:04:31.116099+00:00 app[web.1]: 10.99.197.226 - - [23/Jul/2019:12:04:31 +0000] "GET /favicon.ico HTTP/1.1" 404 77 "https://alumate.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
Settings.py is here Settings.py在这里
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'XXXXXXXXXXXXXXXX'
DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'rest_framework',
'widget_tweaks',
'boards',
'accounts',
'auths',
'my_universities',
'my_profiles',
'universities',
'charts',
'storages',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'alumate.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 = 'alumate.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media_root')
DEBUG = False
try:
from .local_settings import *
except ImportError:
pass
if not DEBUG:
import django_heroku
django_heroku.settings(locals())
I deleted image files in static folder and ran python manage.py collectstatic
我删除了静态文件夹中的图像文件并运行
python manage.py collectstatic
For the reference to other people who have similar issues, paste the code below to the bottom of settings.py and run heroku logs --tail --all [your app name]
after the deployment. 要参考其他有类似问题的人,请将下面的代码粘贴到settings.py的底部,并在部署后运行
heroku logs --tail --all [your app name]
。
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'ERROR'),
},
},
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.