django默认页面,当debug = True [英] django default page when debug=True
本文介绍了django默认页面,当debug = True的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法将所有不匹配的网址重定向到django中的某个视图?我无法正常使用404页面,因为我有 Debug = True
。有没有办法这样做?
Is there any way to redirect all unmatched urls to a certain view in django? I can't use 404 page normally, as i have Debug = True
. Is there any way to do so?
推荐答案
这是一个黑客,但它很简单 - 添加一个匹配的网址在其他网址结尾的任何内容
It's kind of a hack, but it's simple enough - add a url that will match anything at the end of your other urls
url(r'^.*', 'myapp.my_custom_errorview'),
请记住,你必须将放在最后,否则会覆盖所有其他网址。
Remembre that yiou have to put it last, else it will override all other urls.
这篇关于django默认页面,当debug = True的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文