from tastypie.resources import ModelResource
from blog.models import Post, Comment
from tastypie.authorization import Authorization
from tastypie import fields
@@ -152,8 +152,864 @@
 t fields
+%0A%0Aclass PostResource(ModelResource):%0A  author = fields.CharField(attribute=%22author%22)%0A  title = fields.CharField(attribute=%22title%22)%0A  text = fields.CharField(attribute=%22text%22)%0A  is_public = fields.BooleanField(attribute=%22is_public%22, use_in=%22detail%22)%0A  comments_list = fields.ToManyField('blog.api.CommentResource', %22comment_set%22, related_name=%22post%22, null=True, use_in=%22detail%22)%0A  class Meta:%0A    queryset = Post.objects.all()%0A    resource_name = 'post'%0A    authorization = Authorization()%0A    always_return_data = True%0A%0Aclass CommentResource(ModelResource):%0A  author = fields.CharField(attribute=%22author%22)%0A  text = fields.CharField(attribute=%22text%22)%0A  post = fields.ToOneField('blog.api.PostResource', 'post')%0A  class Meta:%0A    queryset = Comment.objects.all()%0A    resource_name = 'comment'%0A    authorization = Authorization()%0A    always_return_data = True

Create REST api