Skip to content

Instantly share code, notes, and snippets.

@edsu
Created August 30, 2011 02:54
Show Gist options
  • Select an option

  • Save edsu/1180059 to your computer and use it in GitHub Desktop.

Select an option

Save edsu/1180059 to your computer and use it in GitHub Desktop.
tastypie resources module
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