[Django]-Heroku server error (500) when Debug = False , whitenoise could not find style.css

14πŸ‘

βœ…

Added this in the settings.py

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
             'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
        },
    },
}

Got the errors in the log
Apparently there was a mismatch with the names of the folders in the remote server and my local machine

8πŸ‘

Try making migrations with:

heroku run python manage.py makemigrations

heroku run python manage.py migrate

I had the same issue, but this solved it.

4πŸ‘

While turning off Debugging.
You need to provide ALLOWED_HOSTS in a list. Please check Django documentation for more..

Debug = False
ALLOWED_HOSTS = ['xyz.com']

3πŸ‘

You can’t use SQLite3 on Heroku. Switch to Postgres.

3πŸ‘

You need to provide ALLOWED_HOSTS

Debug = False
ALLOWED_HOSTS = [".herokuapp.com"]

And Heroku you should use PostgreSQL

https://github.com/kennethreitz/dj-database-url

3πŸ‘

In my case it was due to conflict between
django staticfiles and django _heroku staticfiles

I had to disable one of them.

Either do this,

 ` INSTALLED_APPS={
            .
            .
            #django.contrib.staticfiles,
  }
  django_heroku.settings(locals())` #in end of settings.py

Or do this

    `INSTALLED_APPS={
            .
            .
            django.contrib.staticfiles,
      }
     django_heroku.settings(locals(),staticfiles=False)` #in end of settings.py

Or if you are using whitenoise ,disable staticfiles for both django and django_heroku.

Leave a comment