2016-03-23 17 views
0

私はherokuで自分のWebサイトをホストしようとしていますが、上記のようにホストされたページでエラーが発生します。トレースバックを実行すると、次のような結果が得られます。サーバーが予期しない内部サーバーエラー(ウェイトレスによって生成された)を受けました

[email protected]:~/development/hellowebapp$ heroku logs -t 
2016-03-23T06:24:55.597710+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/waitress/task.py", line 169, in service 
2016-03-23T06:24:55.597711+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/waitress/task.py", line 388, in execute 
2016-03-23T06:24:55.597713+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/base.py", line 119, in __call__ 
2016-03-23T06:24:55.597712+00:00 app[web.1]:  app_iter = self.channel.server.application(env, start_response) 
2016-03-23T06:24:55.597713+00:00 app[web.1]:  return self.application(environ, start_response) 
2016-03-23T06:24:55.597714+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__ 
2016-03-23T06:24:55.597716+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 175, in get_response 
2016-03-23T06:24:55.597716+00:00 app[web.1]:  response = self.get_exception_response(request, resolver, 404) 
2016-03-23T06:24:55.597715+00:00 app[web.1]:  response = self.get_response(request) 
2016-03-23T06:24:55.597717+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 90, in get_exception_response 
2016-03-23T06:24:55.597718+00:00 app[web.1]:  response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) 
2016-03-23T06:24:55.597718+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 268, in handle_uncaught_exception 
2016-03-23T06:24:55.597721+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/views/defaults.py", line 45, in server_error 
2016-03-23T06:24:55.597719+00:00 app[web.1]:  return callback(request, **param_dict) 
2016-03-23T06:24:55.597722+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/backends/django.py", line 74, in render 
2016-03-23T06:24:55.597721+00:00 app[web.1]:  return http.HttpResponseServerError(template.render()) 
2016-03-23T06:24:55.597723+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 209, in render 
2016-03-23T06:24:55.597720+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view 
2016-03-23T06:24:55.597723+00:00 app[web.1]:  return self.template.render(context) 
2016-03-23T06:24:55.597724+00:00 app[web.1]:  return self._render(context) 
2016-03-23T06:24:55.597724+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 201, in _render 
2016-03-23T06:24:55.597725+00:00 app[web.1]:  return self.nodelist.render(context) 
2016-03-23T06:24:55.597720+00:00 app[web.1]:  response = view_func(request, *args, **kwargs) 
2016-03-23T06:24:55.597725+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 903, in render 
2016-03-23T06:24:55.597727+00:00 app[web.1]:  return node.render(context) 
2016-03-23T06:24:55.597726+00:00 app[web.1]:  bit = self.render_node(node, context) 
2016-03-23T06:24:55.597727+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 917, in render_node 
2016-03-23T06:24:55.597728+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader_tags.py", line 135, in render 
2016-03-23T06:24:55.597728+00:00 app[web.1]:  return compiled_parent._render(context) 
2016-03-23T06:24:55.597729+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 201, in _render 
2016-03-23T06:24:55.597729+00:00 app[web.1]:  return self.nodelist.render(context) 
2016-03-23T06:24:55.597730+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 903, in render 
2016-03-23T06:24:55.597731+00:00 app[web.1]:  bit = self.render_node(node, context) 
2016-03-23T06:24:55.597731+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 917, in render_node 
2016-03-23T06:24:55.597732+00:00 app[web.1]:  return node.render(context) 
2016-03-23T06:24:55.597732+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/templatetags/static.py", line 105, in render 
2016-03-23T06:24:55.597733+00:00 app[web.1]:  url = self.url(context) 
2016-03-23T06:24:55.597734+00:00 app[web.1]:  return static(path) 
2016-03-23T06:24:55.597734+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 16, in url 
2016-03-23T06:24:55.597735+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 9, in static 
2016-03-23T06:24:55.597736+00:00 app[web.1]:  return staticfiles_storage.url(path) 
2016-03-23T06:24:55.597736+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 131, in url 
2016-03-23T06:24:55.597737+00:00 app[web.1]:  hashed_name = self.stored_name(clean_name) 
2016-03-23T06:24:55.597737+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 280, in stored_name 
2016-03-23T06:24:55.597739+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 94, in hashed_name 
2016-03-23T06:24:55.597739+00:00 app[web.1]:  (clean_name, self)) 
2016-03-23T06:24:55.597738+00:00 app[web.1]:  cache_name = self.clean_name(self.hashed_name(name)) 
2016-03-23T06:24:55.597740+00:00 app[web.1]: ValueError: The file 'images/favicon.png' could not be found with <whitenoise.django.GzipManifestStaticFilesStorage object at 0x7fed94e53a50>. 
2016-03-23T06:25:08.874468+00:00 heroku[router]: at=info method=GET path="/" host=lit-fortress-70950.herokuapp.com request_id=952f7035-5cb7-4174-9439-a0767971e269 fwd="124.124.52.34" dyno=web.1 connect=4ms service=33ms status=500 bytes=269 
2016-03-23T06:25:08.860148+00:00 app[web.1]: LOOK AT HERE >>> False 
2016-03-23T06:25:08.887408+00:00 app[web.1]: ERROR:waitress:Exception when serving/
2016-03-23T06:25:08.887417+00:00 app[web.1]: Traceback (most recent call last): 
2016-03-23T06:25:08.887419+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/waitress/channel.py", line 336, in service 
2016-03-23T06:25:08.887420+00:00 app[web.1]:  task.service() 
2016-03-23T06:25:08.887421+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/waitress/task.py", line 169, in service 
2016-03-23T06:25:08.887421+00:00 app[web.1]:  self.execute() 
2016-03-23T06:25:08.887422+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/waitress/task.py", line 388, in execute 
2016-03-23T06:25:08.887423+00:00 app[web.1]:  app_iter = self.channel.server.application(env, start_response) 
2016-03-23T06:25:08.887423+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/whitenoise/base.py", line 119, in __call__ 
2016-03-23T06:25:08.887424+00:00 app[web.1]:  return self.application(environ, start_response) 
2016-03-23T06:25:08.887425+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__ 
2016-03-23T06:25:08.887432+00:00 app[web.1]:  response = self.get_response(request) 
2016-03-23T06:25:08.887433+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response 
2016-03-23T06:25:08.887433+00:00 app[web.1]:  response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) 
2016-03-23T06:25:08.887434+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 268, in handle_uncaught_exception 
2016-03-23T06:25:08.887435+00:00 app[web.1]:  return callback(request, **param_dict) 
2016-03-23T06:25:08.887435+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view 
2016-03-23T06:25:08.887436+00:00 app[web.1]:  response = view_func(request, *args, **kwargs) 
2016-03-23T06:25:08.887436+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/views/defaults.py", line 45, in server_error 
2016-03-23T06:25:08.887437+00:00 app[web.1]:  return http.HttpResponseServerError(template.render()) 
2016-03-23T06:25:08.887438+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/backends/django.py", line 74, in render 
2016-03-23T06:25:08.887438+00:00 app[web.1]:  return self.template.render(context) 
2016-03-23T06:25:08.887439+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 209, in render 
2016-03-23T06:25:08.887439+00:00 app[web.1]:  return self._render(context) 
2016-03-23T06:25:08.887440+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 201, in _render 
2016-03-23T06:25:08.887441+00:00 app[web.1]:  return self.nodelist.render(context) 
2016-03-23T06:25:08.887441+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 903, in render 
2016-03-23T06:25:08.887442+00:00 app[web.1]:  bit = self.render_node(node, context) 
2016-03-23T06:25:08.887443+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 917, in render_node 
2016-03-23T06:25:08.887443+00:00 app[web.1]:  return node.render(context) 
2016-03-23T06:25:08.887446+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 903, in render 
2016-03-23T06:25:08.887447+00:00 app[web.1]:  bit = self.render_node(node, context) 
2016-03-23T06:25:08.887447+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 917, in render_node 
2016-03-23T06:25:08.887453+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 131, in url 
2016-03-23T06:25:08.887448+00:00 app[web.1]:  return node.render(context) 
2016-03-23T06:25:08.887454+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 280, in stored_name 
2016-03-23T06:25:08.887449+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/templatetags/static.py", line 105, in render 
2016-03-23T06:25:08.887449+00:00 app[web.1]:  url = self.url(context) 
2016-03-23T06:25:08.887444+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/loader_tags.py", line 135, in render 
2016-03-23T06:25:08.887450+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 16, in url 
2016-03-23T06:25:08.887445+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 201, in _render 
2016-03-23T06:25:08.887451+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 9, in static 
2016-03-23T06:25:08.887444+00:00 app[web.1]:  return compiled_parent._render(context) 
2016-03-23T06:25:08.887451+00:00 app[web.1]:  return static(path) 
2016-03-23T06:25:08.887446+00:00 app[web.1]:  return self.nodelist.render(context) 
2016-03-23T06:25:08.887452+00:00 app[web.1]:  return staticfiles_storage.url(path) 
2016-03-23T06:25:08.887453+00:00 app[web.1]:  hashed_name = self.stored_name(clean_name) 
2016-03-23T06:25:08.887454+00:00 app[web.1]:  cache_name = self.clean_name(self.hashed_name(name)) 
2016-03-23T06:25:08.887455+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 94, in hashed_name 
2016-03-23T06:25:08.887456+00:00 app[web.1]:  (clean_name, self)) 
2016-03-23T06:25:08.887456+00:00 app[web.1]: ValueError: The file 'images/favicon.png' could not be found with <whitenoise.django.GzipManifestStaticFilesStorage object at 0x7fed94e53a50>. 

私は、何も変更することなく、自分のlocalhostで正常に動作しています。私は私の 'projectname/static/images'フォルダにfavicon.pngを持っています。

import os 

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 
MEDIA_URL = '/media/' 


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

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

# SECURITY WARNING: don't run with debug turned on in production! 
DEBUG = False 

ALLOWED_HOSTS = ['*'] 


# Application definition 

INSTALLED_APPS = (
    'collection', 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'django.contrib.humanize', 
    'registration', 
) 

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', 
    'django.middleware.security.SecurityMiddleware', 
) 

ROOT_URLCONF = 'hellowebapp.urls' 

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [], 
     '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 = 'hellowebapp.wsgi.application' 


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

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


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

LANGUAGE_CODE = 'en-us' 

TIME_ZONE = 'UTC' 

USE_I18N = True 

USE_L10N = True 

USE_TZ = True 


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

STATIC_URL = '/static/' 
#STATIC_ROOT = 'staticfiles' 
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') 
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) 

ACCOUNT_ACTIVATION_DAYS = 7 

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' 
DEFAULT_FROM_EMAIL = '[email protected]' 
EMAIL_HOST_USER = '' 
EMAIL_HOST_PASSWORD = '' 
EMAIL_USE_TLS = False 
EMAIL_PORT = 1025 

LOGIN_REDIRECT_URL = "home" 


#Cookie name. this can be whatever you want 
SESSION_COOKIE_NAME='sessionid' # use the sessionid in your views code 
#the module to store sessions data 
SESSION_ENGINE='django.contrib.sessions.backends.db' 
#age of cookie in seconds (default: 2 weeks) 
SESSION_COOKIE_AGE= 24*60*60*7 # the number of seconds for only 7 for example 
#whether a user's session cookie expires when the web browser is closed 
SESSION_EXPIRE_AT_BROWSER_CLOSE=False 
#whether the session cookie should be secure (https:// only) 
SESSION_COOKIE_SECURE=False 
+0

(ローカルに) 'python manage.py collectstatic'を実行し、エラーがないことを確認してください。 –

+0

また、エラーメッセージが 'whitenoise.django.GzipManifestStaticFilesStorage'を参照していますが、投稿したファイルがどこでも' STATICFILES_STORAGE'を設定していないので、完全な設定ファイルを投稿していないことは間違いありません。 –

+0

D. Evansに返答してくれてありがとう、実際これは私の完全なコードです。 STATICFILES_STORAGEを明示的に定義する必要がありますか?私はそれが何をしているのか分からないのですか? –

答えて

0

Settings.pyは解決策を見つけました。実際には私の ".gitingnore"ファイルに* .pngを誤って追加してしまったので、ファイルはgitで無視されていました。それを削除すると問題が解決しました。

関連する問題