Skip to content

Commit 4e03518

Browse files
committed
required=False for nullable relationships
1 parent 7394dce commit 4e03518

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rest_framework/utils/field_mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def get_relation_kwargs(field_name, relation_info):
215215
# If this field is read-only, then return early.
216216
# No further keyword arguments are valid.
217217
return kwargs
218-
if model_field.has_default():
218+
if model_field.has_default() or model_field.null:
219219
kwargs['required'] = False
220220
if model_field.null:
221221
kwargs['allow_null'] = True

0 commit comments

Comments
 (0)