首先需要在settings中将DEBUG由原来的True改为False
DEBUG = False
设置
## ALLOWED_HOSTS列表为了防止黑客入侵,只允许列表中的ip地址访问,ALLOWED_HOSTS = ['localhost','www.example.com', '127.0.0.1']
ALLOWED_OSTS = ["*", ]
任何一个应用的views.py中
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')
在工程的urls.py中
from Demo_one import views
handler404 = views.page_not_found
handler500 = views.page_error