Last active
August 29, 2015 14:00
-
-
Save marteinn/b4a88868f0366904de0d to your computer and use it in GitHub Desktop.
How to use Tastypies resource serialization outside the api
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
""" | |
Credit to the parker library (https://github.com/coxmediagroup/parker/) and their TastyPieHandler. | |
""" | |
req = HttpRequest() | |
resource = YourResource() | |
bundle = resource.build_bundle(obj=your_model) | |
bundle = resource.full_dehydrate(bundle) | |
bundle = resource.alter_detail_data_to_serialize(req, bundle) | |
json_string = resource.serialize(req, bundle, 'application/json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment