mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Blank relational fields map to required=False serializer fields. Closes #3210.
This commit is contained in:
parent
472784b70a
commit
650866cc43
|
@ -226,7 +226,7 @@ def get_relation_kwargs(field_name, relation_info):
|
||||||
# No further keyword arguments are valid.
|
# No further keyword arguments are valid.
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
if model_field.has_default() or model_field.null:
|
if model_field.has_default() or model_field.blank or model_field.null:
|
||||||
kwargs['required'] = False
|
kwargs['required'] = False
|
||||||
if model_field.null:
|
if model_field.null:
|
||||||
kwargs['allow_null'] = True
|
kwargs['allow_null'] = True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user