django default page when debug=True

2019-09-15 10:22发布

问题:

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?

回答1:

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 url