Implementing http404 in django

♀尐吖头ヾ 提交于 2019-12-20 06:49:09

问题


Implementing page not found in django and have looked at the documentation 404

I do not get a page not found error as yet what ami doing here

In my code in urls i have done the following,

  url(r'^$', 'site_config.views.pagenotfound')

from django.http import Http404

 def pagenotfound(request):
   return render_to_response('polls/pagenotfound.html', {})

回答1:


The way you handle 404 and 500 in django is: by default, in the templates directory, create a 404.html

If you need a custom handler, just add these to urls.py

handler404 = 'views.page_not_found_custom'    
handler500 = 'views.page_error_found_custom'    

design the 404.html page the way you want



来源:https://stackoverflow.com/questions/12180281/implementing-http404-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!