title: Object of type Company is not JSON serializable when writing tests
body: <p>I'm having an issue in Django RestFramework in testing.
  I have the following test:</p>
  
  <pre><code>def test_update_coupon(self):
          response = self.make_coupon_request(
              kind="put",
              version="v1",
              id=2,
              data=self.valid_coupon_data
          )
          self.assertEqual(response.status_code, status.HTTP_200_OK)
  </code></pre>
  
  <p>Where make_coupon_request has a return of:</p>
  
  <pre><code>return self.client.put(
      reverse("coupon",
          kwargs={
              "version": kwargs["version"],
              "pk": kwargs["id"]
          }
      ),
      data=json.dumps(kwargs["data"]),
      content_type='application/json'
  )
  </code></pre>
  
  <p>and valid_coupon_data where the problem is occurring is:</p>
  
  <pre><code>self.valid_coupon_data = {
      "company": Company.objects.get(id=1),
      "name": "Coupon Updated",
      "added": "2018-11-30",
      "code": "TESTCODE"
  }
  </code></pre>
  
  <p><strong>edit - An example Company that would be in this structure is:</strong></p>
  
  <pre><code>            {
                  "id": 1,
                  "name": "test",
                  "added": "2018-11-30"
              },
  </code></pre>
  
  <p>So the total structure would look like:</p>
  
  <pre><code>self.valid_coupon_data = {
          "company": {
                      "id": 1,
                      "name": "test",
                      "added": "2018-11-30"
                  },
          "name": "Coupon Updated",
          "added": "2018-11-30",
          "code": "TESTCODE"
      }
  </code></pre>
  
  <p>The error I am getting is in <em>make_coupon_request</em> that json.dumps cannot serialize <em>valid_coupon_data</em>:</p>
  
  <pre><code>"TypeError: Object of type Company is not JSON serializable"
  </code></pre>
  
  <p>I have a serializer for Company:</p>
  
  <pre><code>class CompanySerializer(serializers.ModelSerializer):
      coupons = CouponSerializer(many=True, read_only=True)
  
      class Meta:
          model = Company
          fields = ("name", "added", "coupons")
  </code></pre>
  
  <p>And for coupon:</p>
  
  <pre><code>class CouponSerializer(serializers.ModelSerializer):
      class Meta:
          model = Coupon
          fields = ("company", "name", "added", "code")
  </code></pre>
  
  <p>Basically I know that somehow I need to use a serializer in order to make my test work, as json.dumps isn't accepting the raw Company object... but I am not sure how nor do I quite understand why.</p>
  
  <p>Here are my 2 models for reference:</p>
  
  <pre><code>class Company(models.Model):
      name = models.CharField(max_length=255, null=False)
  
      class Meta:
          verbose_name_plural = "Companies"
  
  
  class Coupon(models.Model):
      company = models.ForeignKey(
          Company, on_delete=models.CASCADE, related_name='coupons')
      name = models.CharField(max_length=100)
      added = models.DateField(auto_now_add=True)
      code = models.CharField(max_length=255, null=False)
  </code></pre>