Created
August 13, 2013 08:49
-
-
Save GVRV/6219176 to your computer and use it in GitHub Desktop.
tastypie example
This file contains 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
# 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