title: custom message in raise PermissionDenied not working in Django rest
body: <p>I tried  <strong>raise PermissionDenied(&quot;Anonymous user&quot;)</strong> inside a custom permission function but the message I wrote is not showing in the api response. Instead, it is showing the default forbidden message that says <strong>you dont have permission to perform this action</strong></p>
  <p>My snippet is here:</p>
  <pre><code>class CustomPermission(BasePermission):
      &quot;&quot;&quot;
          returns permission based on the request method and slug
      &quot;&quot;&quot;
  
      def has_permission(self, request,view):
          slug = request.resolver_match.kwargs[&quot;slug&quot;]
          if slug is not None and request.method == 'POST':
              if slug == &quot;abc&quot;:
                  user = request.user
                  if user.is_staff:
                      return True
                  if user.is_anonymous:
                      print(&quot;iam here&quot;)
                      raise PermissionDenied(&quot;Anonymous user&quot;)
              elif slug == &quot;mnp&quot;:
                  return True
          else:
              return True
  </code></pre>
  <p><strong>Here in the above code I reached to (&quot;iam here&quot;) but anonymous user is not printing instead showing the default message.</strong></p>