title: How to stop Django Rest Framework from rendering html for exceptions
body: <p>I have set <code>Debug=False</code> in my settings to test my error handling in my client, but am getting an html payload (<code>&lt;h1&gt;Server Error (500)&lt;/h1&gt;</code>) from an exception in this api_view:</p>
  
  <pre><code>@api_view(['POST', ])
  @permission_classes((permissions.IsAuthenticated,))
  @renderer_classes((JSONRenderer,))
  @transaction.atomic()
  def process_payment(request):
  
      # Do some work
  
      return Response(serializer.data)
  </code></pre>
  
  <p>I am making the call from AngularJS, using the default Accept headers: <code>Accept: application/json, text/plain, */*</code></p>
  
  <p>The documentation on the <a href="http://www.django-rest-framework.org/api-guide/renderers/" rel="nofollow">Renderers</a> page seems to indicate that I can expect json if I'm explicitly using the json renderer for successful responses.</p>
  
  <p>Is this a side effect of local development? I don't want to have to write code to test for non-json responses if I can help it.</p>
  
  <p>UPDATE</p>
  
  <p>I should have mentioned that I wildcarded <code>ALLOWED_HOSTS</code> for this test, so I don't think that is the problem.</p>
  
  <p>Looking through the default error handling in DRF, it looks like any exception that is not either derived from <code>APIException</code> or is an <code>Http404</code> or <code>PermissionDenied</code> will result in a Response=None. This is where I'm seeing the html response, so the solution is probably a Django custom error handler as indicated in the comment below.</p>