400500ページをカスタマイズ

Falseの最初の必要性は、元の真からの設定のDEBUGに変更します

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

おすすめ

転載: www.cnblogs.com/bestjdg/p/11938937.html