Created
October 4, 2012 04:24
-
-
Save bohde/3831468 to your computer and use it in GitHub Desktop.
Tastypie helpers for view reuse.
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 MyResource(ModelResource): | |
def model_to_data(self, model, request=None): | |
bundle = self.build_bundle(obj=model, request=request) | |
return self.full_dehydrate(bundle).data | |
def resource_for_request(resource_name, filters, request): | |
resource = v1_dns_api.canonical_resource_for(resource_name) | |
objects = resource.get_object_list(request).filter(filters) | |
return (resource.model_to_data(model, request) for model in objects) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment