mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-30 05:24:00 +03:00
Fix for emptystring as nullable FK
This commit is contained in:
parent
936fdfb78e
commit
733f03fba3
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user