Skip to content

Instantly share code, notes, and snippets.

@p7k
Created April 27, 2011 19:39
Show Gist options
  • Save p7k/945012 to your computer and use it in GitHub Desktop.
Save p7k/945012 to your computer and use it in GitHub Desktop.
elif isinstance(value, (int, long)):
model = self.fk_resource._meta.object_class
try:
obj = model.objects.get(pk=value)
except (model.DoesNotExist, model.MultipleObjectsReturned):
raise ApiFieldError("Could not find the provided object via PK '%s'." % value)
else:
return self.fk_resource.full_dehydrate(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment