mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
required=False for nullable relationships
This commit is contained in:
parent
7394dcec9e
commit
4e03518438
|
@ -215,7 +215,7 @@ def get_relation_kwargs(field_name, relation_info):
|
|||
# If this field is read-only, then return early.
|
||||
# No further keyword arguments are valid.
|
||||
return kwargs
|
||||
if model_field.has_default():
|
||||
if model_field.has_default() or model_field.null:
|
||||
kwargs['required'] = False
|
||||
if model_field.null:
|
||||
kwargs['allow_null'] = True
|
||||
|
|
Loading…
Reference in New Issue
Block a user