mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04: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:
|
if self.read_only:
|
||||||
return
|
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)
|
value = data.get(field_name)
|
||||||
|
|
||||||
if value in (None, '') and not self.null:
|
if value in (None, '') and not self.null:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user