6
22
2009
1

Django 非 Debug 模式下使用自定义的 404 500 页面

如题,需要在 urls.py 中 加入 :

handler404 = 'main.views.custom.Error_404'
handler500 = 'main.views.custom.Error_500'

 其中字符串为你自己的 app 的处理函数

像这样 :

from django.http import HttpResponse
from django.http import HttpResponseRedirect

def Error_404(request):
    return HttpResponse("404")
   
def Error_500(request):
    return HttpResponse("500")

 

 

 

Category: Python | Tags: python django | Read Count: 4930
daftar judi bola ter 说:
2019年4月03日 20:14

Thanks for sharing this useful information here


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com