Created
October 11, 2011 02:21
-
-
Save bohde/1277114 to your computer and use it in GitHub Desktop.
Example of using obj_get_list in a standard django view
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
| from annoying.decorators import render_to | |
| from snipts.api import PublicTagResource | |
| @render_to('home.html') | |
| def home(request): | |
| tr = PublicTagResource() | |
| tags = tr.cached_obj_get_list() | |
| bundles = (tr.build_bundle(request=request, obj=tag) for tag in tags) | |
| dehydrated = [tr.full_dehydrate(bundle) for bundle in bundles] | |
| return { | |
| 'tags': tr.serialize(None, {'objects': dehydrated}, 'application/json'), | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment