title: Serializing a tree in Django
body: <p>is there any simple way to serialize a tree given by a model such as the Category shown below?</p>
  
  <p>I'd like to get a json object like:</p>
  
  <pre><code>[ { 'name': 'cat1',
      'children': [ { 'name': 'cat11',
                      'children': [ ... ]
                  ]
    }
    ...
  ]
  </code></pre>
  
  <p>Thanks</p>
  
  <pre><code>class Category(MPTTModel):
      name = models.CharField(max_length=50, unique=True)
      parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
      order_key = models.IntegerField()
  
      class Meta:
          verbose_name_plural = 'Categories'
  
      class MPTTMeta:
          order_insertion_by = ['order_key']
  
      def __unicode__(self):
          return "%s" %(self.name)
  </code></pre>