When Debug = True
django returns a Page not found (404)
page which is totally fine
But when I change Debug = False
django return a Server Error (500)
and the server shows these requests made:
[30/Jul/2022 12:29:44] "GET /__reload__/events/ HTTP/1.1" 500 145
[30/Jul/2022 12:29:44] "GET /__reload__/events/ HTTP/1.1" 500 145
[30/Jul/2022 12:29:44] "GET /sdfs HTTP/1.1" 500 145
[30/Jul/2022 12:29:45] "GET /favicon.ico HTTP/1.1" 302 0
myproject main urls.py
from django.conf.urls import handler404
handler404 = 'myproject.views.custom_page_not_found'
please note here that hander404 is not found by django handler404 not found
my views.py
def custom_page_not_found(request, exception, template_name="errors/404.html"):
return render(request, template_name, status=404)
Please not here django cannot find the exception
parameter
exception parameter not found
In previous community questions i could not find any question that points to the exception
parameter not found issue. Please note that i am not using django templates {% %}
in my 404.html
file
I think when django does not find the exception parameter it returns server error 500.