django default page when debug=True

2019-09-15 10:15发布

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?

标签: django url
1条回答
一纸荒年 Trace。
2楼-- · 2019-09-15 10:59

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.

查看更多
登录 后发表回答