title: Django Rest Framework Response is not JSON serializable error
body: <p>I have the following custom exception handler in Django REST framework.</p>
  
  <pre><code>class ErrorMessage:
      def __init__(self, message):
          self.message = message
  
  def insta_exception_handler(exc, context):
      response = {}
  
      if isinstance(exc, ValidationError):
          response['success'] = False
          response['data'] = ErrorMessage("Validation error")
  
      return Response(response)
  </code></pre>
  
  <p>I want a JSON output as shown below</p>
  
  <pre><code>"success":false,
  "data":{ "message" : "Validation error" }
  </code></pre>
  
  <p>But I get the error <code>TypeError: Object of type 'ErrorMessage' is not JSON serializable</code>. Why is a class as simple as <code>ErrorMessage</code> above not JSON serializable? How can I solve this problem?</p>