bradrice
bradrice

Reputation: 1755

Wagtail returns 500 error on Debug = False

I can't seem to get my site to display when I set Debug = False in my settings file after getting it to run using a standard setup of wagtail start . If I runserver it runs fine. I change the setting to Debug = False and my site shows the 500 error page.

Just the basic settings file:

from .base import *

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'c1=mbs2t*!^omg&i0xfo_=mle)%_oegt-&@gn)vx5cs0foe%l9'

# SECURITY WARNING: define the correct hosts in production!
ALLOWED_HOSTS = ['*']

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'


try:
    from .local import *
except ImportError:
    pass

Django 2.2.1 Wagtail 2.5

Upvotes: 2

Views: 2870

Answers (3)

allcaps
allcaps

Reputation: 11248

When Django runs with DEBUG=False you won't get the yellow error pages. That doesn't mean those errors are not raised.

Just configure logging and inspect the logs.
https://docs.djangoproject.com/en/2.2/topics/logging/#django-s-default-logging-configuration

Without a traceback it is hard to solve any issue.

This is how you log to a file:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': '/path/to/django/debug.log',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

This is the Django default logging: https://github.com/django/django/blob/stable/2.2.x/django/utils/log.py

Upvotes: 2

bradrice
bradrice

Reputation: 1755

It turns out I had to collectstatic files.

Upvotes: 4

Neum
Neum

Reputation: 658

I think this same thing caught me a while back. It's because the browser looks for a /favicon.ico file and for some reason Wagtail or Django tries to pass it to a view instead of just 404ing. Try to add the following in the head of your base.html template and see how it goes. Correcting the link to the file path below as needed.

<link rel="shortcut icon" href="{% static 'images/favicon.ico' %}"/>

Upvotes: 0

Related Questions