mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
Update RelatedField#field_from_native coding style
This commit is contained in:
parent
2f5582a1a6
commit
f8a1256b1c
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user