I have production server which has these settings:
DEBUG = False
ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'my.ip.address', 'example.com']
Then in my main urls.py file I have added this:
from django.conf.urls import url, include, handler404, handler500
handler500 = 'main.views.error_500'
handler404 = 'main.views.error_404'
My main.views has these:
def error_404(request):
return render(request, 'main/errors/404.html', status=404)
def error_500(request):
return render(request, 'main/errors/500.html', status=500)
When I deploy my production server and try to open page that does not exists, it should redirect to my error_404 view. However, it redirects to my error_500 view. Why this is happening?