Created
October 10, 2012 21:59
-
-
Save boronine/3868748 to your computer and use it in GitHub Desktop.
This file contains 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
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