title: Adding custom response Headers to APIException
body: <p>I have created a custom exception referring to <a href="http://django-rest-framework.org/api-guide/exceptions.html" rel="noreferrer">http://django-rest-framework.org/api-guide/exceptions.html</a>.</p>
  
  <p>Please know that I have my own authentication backend. Hence I am not using rest_framework's authentication module.</p>
  
  <p>For authentication errors, I want to add 'WWW-Authenticate: Token' header to the response that is sent from the exception.</p>
  
  <p>Any ideas will be very helpful.</p>
  
  <p>Update:</p>
  
  <p>Thanks @Pathétique,
  This is what I ended up doing. </p>
  
  <p>-Have a base view class named BaseView.</p>
  
  <p>-override the handle_exception method to set appropriate headers, in my case 'WWW-Authenticate'.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>class BaseView(APIView):
    def handle_exception(self, exc):
       if isinstance(exc, MYEXCEPTION):
          self.headers['WWW-Authenticate'] = "Token"
          return Response({'detail': exc.detail,
                          status=exc.status_code, exception=True)
  </code></pre>
  
  <p>Your thoughts?</p>