DEV Community

Discussion on: [SOLVED]Why doesn't my Django app display the 404 page even when Debug = False?

Collapse
 
highcenburg profile image
Vicente G. Reyes

Here's my project structure. As on my post, the handlers are on the main urls.py

Collapse
 
pedromendes96 profile image
Pedro Mendes

handler404 = 'portfolio.views.handler500'
handler500 = 'portfolio.views.handler500'

You meant
handler404 = 'portfolio.views.handler404'
handler500 = 'portfolio.views.handler500'

Thread Thread
 
highcenburg profile image
Vicente G. Reyes

oh yeah. I think I already changed that to app.views.handlerX. Still getting the error. It pisses me off.

Thread Thread
 
pedromendes96 profile image
Pedro Mendes

from django.views.default import page_not_found

def handler_404(request, exception):
return page_not_found(request, exception, template_name="errors/404.html")

Thread Thread
 
highcenburg profile image
Vicente G. Reyes

Thank you. There's a little typo on the django.views.default. It should be django.views.defaults.

Anyway, I think it worked. The only question I think I have is if the template should be inside errors or if its ok if the template is inside the template folder together with the other html files.

Thread Thread
 
pedromendes96 profile image
Pedro Mendes

No, that example is from an older project. That path to the template could be any path you want.

Thread Thread
 
highcenburg profile image
Vicente G. Reyes

Got it. Thank you.