title: How to convert factory boy instance as json
body: <p>I have a model that relates to some others and I want to make an instance of model factory with <code>factory boy</code> package and send it as <code>json</code> to rest API in django rest framework.</p>
  <p>UserFactory:</p>
  <pre><code>class UserFactory(factory.django.DjangoModelFactory):
      class Meta:
          model = User
      first_name = factory.Faker('name')
      username = factory.Faker('word')
      language = factory.SubFactory(LanguageFactory)
  </code></pre>
  <p>LanguageFactory:</p>
  <pre><code>class LanguageFactory(factory.django.DjangoModelFactory):
  class Meta:
      model = Language
  
  name = factory.Faker('language_name')
  </code></pre>
  <p>When I use:</p>
  <pre><code>factory.build(dict, FACTORY_CLASS=UserFactory)
  </code></pre>
  <p>it returns:</p>
  <pre><code>{'first_name': &quot;Agent 001&quot;, 'username': 'john_doe', 'language': &lt;Language: Catalan&gt;}
  </code></pre>
  <p>where language is another model factory but I need it as json to post or patch test.</p>
  <p>How would I get something like this?</p>
  <pre><code>{'first_name': &quot;Agent 001&quot;, 'username': 'john_doe', 'language': [{'name': 'English'}, {'name': 'French'}]}
  </code></pre>