title: Serialization of an object with foreign key into json
body: <p>this is in Django:</p>
  
  <pre><code>data = []
  data += serializers.serialize("json", conversation_deal)
  data += serializers.serialize("json", deal_statuses)
  dat = serializers.serialize("json", data)
  return HttpResponse(dat)
  </code></pre>
  
  <p>I would like to save one round trip to the webservice and combine two jsons into one.
  What I tried to do was to serialize each object into json and add them into an array and serialize them again as json.  But it throws an exception.</p>
  
  <p>I also tried to put the two python objects into the array and serialize them all into json, which also failed.</p>
  
  <p>How is this usually done?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Exception:</p>
  
  <pre><code>str: 'str' object has no attribute '_meta'
  </code></pre>
  
  <p><strong>Update 2:</strong></p>
  
  <p>I have some more information, and it seems its somehow Django related the way it serializes the objects.</p>
  
  <p>the following works perfectly fine:</p>
  
  <pre><code>deal_statuses = DealStatus.objects.all()        
  data = serializers.serialize("json", deal_statuses)
  return HttpResponse(data)
  </code></pre>
  
  <p>but this fails..</p>
  
  <pre><code>conversation_deal = Conversation_Deal.objects.filter(conversation_id__in=call_id)
  data = serializers.serialize("json", conversation_deal)
  return HttpResponse(data)
  </code></pre>
  
  <p>This is how Conversation_Deal is modelled:</p>
  
  <pre><code>class Conversation_Deal(models.Model):
      conversation        = models.ForeignKey('Conversation')
      deal                = models.ForeignKey('Deal')
      status              = models.ForeignKey(DealStatus, null=True, blank=True)
  </code></pre>
  
  <p>I found something related to inherited classes <a href="https://docs.djangoproject.com/en/dev/topics/serialization/" rel="nofollow">documentation</a> pointing this out why...Even though I am not inheriting, but the same process worked in my case. Hope this helps someone else. I will post this as an answer soon.</p>