[Solved]-Server Error (500) on Django when template debug is set to False?


For django v 1.5+ , in your settings.py file, Make the configuration
ALLOWED_HOSTS = [‘*’] if you want a quick fix

If you are really going production (and concerned about security), put allowed host names in ALLOWED_HOSTS

this SO link has more info

Setting DEBUG = False causes 500 Error


Use the following LOGGING settings, then you should be able to see the error in the console.

    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'

    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,

remember to set DEBUG = False


I got the 500 Internal Server error after switching DEBUG off as well. Another reason this could happen is if you have an extra / at the start of the relative static path. So replace:

<link rel="stylesheet" href="{% static '/css/somecustom.css' %}">


<link rel="stylesheet" href="{% static 'css/somecustom.css' %}">

i.e. search and replace {% static '/ with {% static ' in your template files.

To understand this further you can read up on the caching behaviour of Django’s ManifestStaticFilesStorage backend.


Go to django admin portal.
Click on sites table and edit the example.com site to your domain name.
It will work.

Leave a comment