Customize 400,500 pages

False first need to be changed in the settings DEBUG from the original True

DEBUG = False

Set up


## ALLOWED_HOSTS列表为了防止黑客入侵,只允许列表中的ip地址访问,ALLOWED_HOSTS = ['localhost','www.example.com', '127.0.0.1']
ALLOWED_OSTS = ["*", ]

views.py any application of

from django.shortcuts import render_to_response
def page_not_found(request, **kwargs):
    return render_to_response('404.html')
 
def page_error(request, **kwargs):
    return render_to_response('500.html')

In engineering in urls.py


from Demo_one import views
handler404 = views.page_not_found
handler500 = views.page_error

Guess you like

Origin www.cnblogs.com/bestjdg/p/11938937.html