I\'d like to do the following:
raise HttpResponseForbidden()
But I get the error:
exceptions must be old-style classes or d
if you want to raise an exception you can use:
from django.core.exceptions import PermissionDenied
def your_view(...):
raise PermissionDenied()
It is documented here :
https://docs.djangoproject.com/en/stable/ref/views/#the-403-http-forbidden-view
As opposed to returing HttpResponseForbidden
, raising PermissionDenied
causes the error to be rendered using the 403.html
template, or you can use middleware to show a custom "Forbidden" view.