在django中实现http404 [英] Implementing http404 in django
本文介绍了在django中实现http404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在django中找不到实现页面,并查看了文档 404
我没有找到一个页面没有找到错误,但是在这里做什么
url(r'^ $','site_config.views pagenotfound')
from django.http import Http404
def pagenotfound(request):
pre>
return render_to_response('polls / pagenotfound.html',{})
解决方案在django中处理404和500的方式是:默认情况下,在templates目录中,创建一个404.html
如果您需要自定义处理程序,只需将其添加到urls.py
handler404 ='views.page_not_found_custom'
handler500 ='views.page_error_found_custom'
按照你想要的方式设计404.html页面
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', {})
解决方案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
这篇关于在django中实现http404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文