title: Why is django not using my custom encoder class?
body: <ol>
  <li>I have two classes: Website and WordpressWebsite. </li>
  <li>WordpressWebsite subclasses Website.</li>
  </ol>
  
  <p>When an instance of WordpressWebsite is being encoded into JSON, only the attributes of WordpressWebsite are present (and none of the attributes of Website). </p>
  
  <p>My goal is to write a custom encoder which will encode a WordpressWebsite as a Website instead. </p>
  
  <p>This is what I have so far: </p>
  
  <pre><code>from django.core.serializers.json import DjangoJSONEncoder
  from websites.models import Website
  
  class WebsiteEncoder(DjangoJSONEncoder):
  
      def default(self, obj):
          raise Exception()  # TEST
          if isinstance(obj, Website) and hasattr(obj, 'website_ptr'):
              return super().default(obj.website_ptr)
          return super().default(obj)
  </code></pre>
  
  <p>I have the following test case:</p>
  
  <pre><code>from django.core import serializers
  from django.test import TestCase
  from websites.models.wordpress import WordpressWebsite
  from websites.serialize import WebsiteEncoder
  
  
  class SerializationTest(TestCase):
  
      def setUp(self):
          self.wordpress = WordpressWebsite.objects.create(
              domain='test.com'
          )
  
      def test_foo(self):
          JSONSerializer = serializers.get_serializer("json")
          json_serializer = JSONSerializer()
          json_serializer.serialize(
              WordpressWebsite.objects.all(),
              cls=WebsiteEncoder
          )
          data = json_serializer.getvalue()
          print(data)
  </code></pre>
  
  <p>This test case runs fine. It does not raise an exception. </p>
  
  <p>Does anyone know why WebsiteEncoder.default is not being invoked? </p>