Django raising 404 with a message

后端 未结 9 1188
有刺的猬
有刺的猬 2020-12-19 05:31

I like to raise 404 with some error message at different places in the script eg: Http404(\"some error msg: %s\" %msg) So, in my urls.py I included:

<         


        
9条回答
  •  臣服心动
    2020-12-19 06:09

    In general, 404 error is "page not found" error - it should not have customizable messages, simply because it should be raised only when a page is not found.

    You can return a TemplateResponse with status parameter set to 404

提交回复
热议问题