title: django deploy to Heroku : Server Error(500)
body: <p>I am trying to deploy my app to heroku.<br>
  Deploy was done correctly but I got Server Error(500).<br>
  When I turned DEBUG true, Sever Error doesn't occurred.<br>
  So I think there is something wrong with loading staticfiles.  </p>
  
  <p>I can't find any notable, critical error in log.<br>
  I have already installed whitenoise, but it doesn't work.</p>
  
  <p>Is there anyone who solves this problem?  </p>
  
  <p>heroku logs</p>
  
  <pre><code>2019-02-26T17:01:26.064554+00:00 heroku[web.1]: State changed from down to starting
  2019-02-26T17:01:34.347474+00:00 heroku[web.1]: Starting process with command `gunicorn project5.wsgi --log-file -`
  2019-02-26T17:01:37.602081+00:00 heroku[web.1]: State changed from starting to up
  2019-02-26T17:01:37.192553+00:00 app[web.1]: [2019-02-26 17:01:37 +0000] [4] [INFO] Starting gunicorn 19.9.0
  2019-02-26T17:01:37.199091+00:00 app[web.1]: [2019-02-26 17:01:37 +0000] [4] [INFO] Listening at: http://0.0.0.0:35760 (4)
  2019-02-26T17:01:37.199669+00:00 app[web.1]: [2019-02-26 17:01:37 +0000] [4] [INFO] Using worker: sync
  2019-02-26T17:01:37.219788+00:00 app[web.1]: [2019-02-26 17:01:37 +0000] [10] [INFO] Booting worker with pid: 10
  2019-02-26T17:01:37.317796+00:00 app[web.1]: [2019-02-26 17:01:37 +0000] [11] [INFO] Booting worker with pid: 11
  2019-02-26T17:01:39.269757+00:00 heroku[router]: at=info method=GET path="/" host=shunka-blog.herokuapp.com request_id=a5a7c921-c0d2-4bc2-8831-371da12d3945 fwd="111.239.176.72" dyno=web.1 connect=0ms service=522ms status=500 bytes=234 protocol=https
  2019-02-26T17:01:39.271879+00:00 app[web.1]: 10.99.220.185 - - [27/Feb/2019:02:01:39 +0900] "GET / HTTP/1.1" 500 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36"
  
  </code></pre>
  
  <p>settings.py</p>
  
  <pre class="lang-py prettyprint-override"><code>import os
  import dj_database_url
  import django_heroku
  
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  DEBUG = False
  
  SECRET_KEY = ***
  
  ALLOWED_HOSTS = []
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'blog5.apps.Blog5Config',
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django.contrib.humanize',
      'markdownx',
      'widget_tweaks',
  ]
  
  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',
  ]
  
  STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  
  ROOT_URLCONF = 'project5.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 = 'project5.wsgi.application'
  
  DATABASES = { 'default': dj_database_url.config() }
  SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  
  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 = 'ja'
  
  TIME_ZONE = 'Asia/Tokyo'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
  STATIC_URL = '/static/'
  
  # STATICFILES_DIRS = (
  #     os.path.join(BASE_DIR, 'static'),
  # )
  
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  MEDIA_URL = '/media/'
  
  os.makedirs(STATIC_ROOT, exist_ok=True)
  
  try:
      from .local_settings import *
  except ImportError:
      pass
  
  django_heroku.settings(locals())
  </code></pre>
  
  <p>wsgi.py</p>
  
  <pre class="lang-py prettyprint-override"><code>import os
  from django.core.wsgi import get_wsgi_application
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project5.settings')
  
  application = get_wsgi_application()
  </code></pre>
  
  <p>Procfile</p>
  
  <pre><code>web: gunicorn project5.wsgi --log-file -
  </code></pre>