Update RelatedField#field_from_native coding style

This commit is contained in:
Mark Aaron Shirley 2012-12-21 11:33:01 -08:00
parent 2f5582a1a6
commit f8a1256b1c

View File

@ -351,13 +351,13 @@ class RelatedField(WritableField):
if self.read_only:
return
if field_name not in data and self.required:
raise ValidationError(self.error_messages['required'])
elif field_name not in data:
try:
value = data[field_name]
except KeyError:
if self.required:
raise ValidationError(self.error_messages['required'])
return
value = data.get(field_name)
if value in (None, '') and not self.null:
raise ValidationError('Value may not be null')
elif value in (None, '') and self.null: