          determine what kind of exception to raise.
          """
          raise exceptions.MethodNotAllowed(request.method)
  
      def permission_denied(self, request, message=None):
          """
          If request is not permitted, determine what kind of exception to raise.
          """
          if request.authenticators and not request.successful_authenticator:
              raise exceptions.NotAuthenticated()
 
</s> remove         raise exceptions.PermissionDenied(detail=message)
 </s> add         raise exceptions.PermissionDenied(detail=message, code=code) </s> remove                     request, message=getattr(permission, 'message', None)
 </s> add                     request,
                    message=getattr(permission, 'message', None),
                    code=getattr(permission, 'code', None) </s> remove                     request, message=getattr(permission, 'message', None)
 </s> add                     request,
                    message=getattr(permission, 'message', None),
                    code=getattr(permission, 'code', None)
    def permission_denied(self, request, message=None, code=None):
          determine what kind of exception to raise.
          """
          raise exceptions.MethodNotAllowed(request.method)
  
    def permission_denied(self, request, message=None, code=None):
          """
          If request is not permitted, determine what kind of exception to raise.
          """
          if request.authenticators and not request.successful_authenticator:
              raise exceptions.NotAuthenticated()
keep keep keep keep replace keep keep keep keep keep
 Pass custom code to PermissionDenied if permission class had one set (#7306) 
rest_framework/views.py