mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Check if RelatedField is required.
This commit is contained in:
parent
c13f132a21
commit
5c680c36e4
|
@ -351,6 +351,11 @@ 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:
|
||||
return
|
||||
|
||||
value = data.get(field_name)
|
||||
|
||||
if value in (None, '') and not self.null:
|
||||
|
|
Loading…
Reference in New Issue
Block a user