Send Custom message in Django PermissionDenied Send Custom message in Django PermissionDenied django django

Send Custom message in Django PermissionDenied


This answer is probably arriving very late for you. But here it is.You can use this in your Django code:

raise PermissionDenied("Custom message")

And then display the custom message using below snippet in the 403.html template:

{% if exception %}  <p>{{ exception }}</p>{% else %}  <p>Static generic message</p>{% endif %}