Last active
December 10, 2015 12:08
Revisions
-
imom0 revised this gist
Jan 2, 2013 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ from tastypie import fields from tastypie.resources import ModelResource, ALL from myapp.models import Note, Comment class NoteResource(ModelResource): comments = fields.ToManyField('myapp.views.CommentResource', 'comments', full=True) class Meta: queryset = Note.objects.all() class CommentResource(ModelResource): note = fields.ToOneField(NoteResource, 'note') class Meta: queryset = Comment.objects.all() filtering = {'note': ALL} -
imom0 created this gist
Jan 2, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ { "meta": { "limit": 3, "next": "/myapp/comment/comment/?note=1&offset=3&limit=3&format=json", "offset": 0, "previous": null, "total_count": 4 }, "objects": [ { "content": "comment 1", "id": "1", "note": "/myapp/note/note/1/", "resource_uri": "/myapp/comment/comment/1/" }, { "content": "comment 3", "id": "3", "note": "/myapp/note/note/1/", "resource_uri": "/myapp/comment/comment/3/" }, { "content": "comment 4", "id": "4", "note": "/myapp/note/note/1/", "resource_uri": "/myapp/comment/comment/4/" } ] }