Created
May 18, 2011 14:19
-
-
Save bohde/978657 to your computer and use it in GitHub Desktop.
Example of ToMany resources in Django Tastypie
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 characters
v1_api = Api(api_name='v1') | |
v1_api.register(BookResource()) | |
# Intentionally left out PageResource |
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 characters
class PageResource(ModelResource): | |
class Meta: | |
queryset = Page.objects.all() | |
include_resource_uri = False | |
class BookResource(ModelResource): | |
pages = ToManyField(PageResource, 'page_set', full=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment