Created
August 30, 2011 02:54
-
-
Save edsu/1180059 to your computer and use it in GitHub Desktop.
tastypie resources module
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
| from tastypie import fields | |
| from tastypie.resources import ModelResource | |
| from tastypie.authorization import DjangoAuthorization | |
| from tastypie.authentication import ApiKeyAuthentication | |
| from tasty.pie.models import Book, Author | |
| class BookResource(ModelResource): | |
| authors = fields.ToManyField('tasty.pie.api.resources.AuthorResource', 'authors', full=True) | |
| class Meta: | |
| queryset = Book.objects.all() | |
| authentication = ApiKeyAuthentication() | |
| authorization = DjangoAuthorization() | |
| class AuthorResource(ModelResource): | |
| book = fields.ForeignKey(BookResource, 'book') | |
| class Meta: | |
| queryset = Author.objects.all() | |
| authentication = ApiKeyAuthentication() | |
| authorization = DjangoAuthorization() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment