[Answer]-Representing Hierarchical Data in Tastypie

1👍

Similar to what silvio mentioned in his reply, i found out that the right way to provide self relationship is by using ToOneField:

class Category(MPTTModel):
    descr = models.CharField(max_length=200)
    parent = TreeForeignField('self', null=True, related_name='children')

class CategoryResource(ModelResource):
    category = fields.ToOneField('self', 'parent', full=True, null=True)

    # Rest of your Resource class

I hope this answer is useful for other people!

Leave a comment