Skip to content

Instantly share code, notes, and snippets.

@bohde
Created October 11, 2011 02:21
Show Gist options
  • Select an option

  • Save bohde/1277114 to your computer and use it in GitHub Desktop.

Select an option

Save bohde/1277114 to your computer and use it in GitHub Desktop.
Example of using obj_get_list in a standard django view
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