Skip to content

Instantly share code, notes, and snippets.

@GVRV
Created August 13, 2013 08:49
Show Gist options
  • Save GVRV/6219176 to your computer and use it in GitHub Desktop.
Save GVRV/6219176 to your computer and use it in GitHub Desktop.
tastypie example
# For address model
class AddressResource(ModelResource):
street_name = fields.CharField()
suburb = fields.CharField()
# For organization model
class OrganizationResource(ModelResource):
address = fields.ToOneField(AddressResource, 'address')
# Now when you get /api/v1/organization
# in the JSON that is returned, each organization
# will also have the address for the address
# that is related to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment