Fix for emptystring as nullable FK

This commit is contained in:
Tom Christie 2012-12-08 12:48:38 +00:00
parent 936fdfb78e
commit 733f03fba3

View File

@ -351,9 +351,9 @@ class RelatedField(WritableField):
value = data.get(field_name) value = data.get(field_name)
if value is None and not self.blank: if value in (None, '') and not self.blank:
raise ValidationError('Value may not be null') raise ValidationError('Value may not be null')
elif value is None and self.blank: elif value in (None, '') and self.blank:
into[(self.source or field_name)] = None into[(self.source or field_name)] = None
else: else:
into[(self.source or field_name)] = self.from_native(value) into[(self.source or field_name)] = self.from_native(value)