Skip to content

Instantly share code, notes, and snippets.

@boronine
Created October 10, 2012 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boronine/3868748 to your computer and use it in GitHub Desktop.
Save boronine/3868748 to your computer and use it in GitHub Desktop.
class MyResource(ModelResource):
# Workaround for this issue:
# https://github.com/toastdriven/django-tastypie/issues/518
def hydrate(self, bundle):
for field_name, field_obj in self.fields.items():
if field_name == 'resource_uri':
continue
if not field_obj.blank and not bundle.data.has_key(field_name):
raise ApiFieldError("The '%s' field has no data and doesn't allow a default or null value." % field_name)
return bundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment