Skip to content

Instantly share code, notes, and snippets.

@bohde
Created July 23, 2011 02:54
Show Gist options
  • Save bohde/1100897 to your computer and use it in GitHub Desktop.
Save bohde/1100897 to your computer and use it in GitHub Desktop.
Return the authenticated user if the pk is 'self'
class UserResource(ModelResource):
def cached_obj_get(self, request=None, **kwargs):
if request and 'id' in kwargs and kwargs['id'] == 'self':
return request.user
return super(UserResource, self).cached_obj_get(request, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment