Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

handler404 returning Server Error (500) instead of 404.html - Django/Python

Tags:

python

django

I spent several hours on this code and could not get to find out why I am getting server error (500) instead of 404.html in django program. Please see below codes and could someone help?

settings.py: 
DEBUG = False
ALLOWED_HOSTS = ['*']

urls.py: (app is mysite)
handler404 = "mysite.views.error_404"

views.py: 
def error_404(request, exception):
    return render(request, '404.html')
404.html:
{% extends "base.html" %}
{% load static %}
{% block main %}

some html text here

{% endblock %}

Error message from log:

like image 842
ECHO Avatar asked Nov 04 '25 12:11

ECHO


1 Answers

Try getting rid of all the extend commands from your 404 page and render a plain HTML page with no Django extends.

like image 88
Maxwell Avatar answered Nov 06 '25 01:11

Maxwell