Django raising 404 with a message

后端 未结 9 1163
有刺的猬
有刺的猬 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:13

    if you want to raise some sort of static messages for a particular view , you can do as follows:-

    from django.http import Http404
    
    def my_view(request):
      raise Http404("The link seems to be broken")
    

提交回复
热议问题