toastdriven/django-tastypie — Issue #277: Not support Recursive Model
Author: imjuni
Created: 2011-11-02 05:22:17+00:00
State: open

Hello, I am development my web service.

I create recursive model. Example below,

class Article(models.Model):
date = models.DateField()
parent = models.ForeignKey('self', null=True, blank=True, related_name='subarticles')

Article is a recursive model. It is a have recursive reference. I want service that model.

class ArticleResource(ModelResource):
class Meta():
queryset = Article.objects.all()
resource_name = "Articles"
parent = fields.ToOneField('self', "Articles")

But, That is invalid syntax and do not executable. I try,

fields.ToOneField(ArticleResource, "Articles")

It is same. Because Article is not register at namespace.

Recursive Model don't support until now? Or Do i try wrong method? Please reply for me. thank.