How do I raise a Response Forbidden in django

前端 未结 4 1134
情深已故
情深已故 2020-12-12 23:09

I\'d like to do the following:

raise HttpResponseForbidden()

But I get the error:

exceptions must be old-style classes or d         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 23:43

    Return it from the view as you would any other response.

    from django.http import HttpResponseForbidden
    
    return HttpResponseForbidden()
    

提交回复
热议问题