mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Propogate 'default' from model_field to serializer field
This commit is contained in:
parent
3875d3284e
commit
be9eb25baf
|
@ -101,6 +101,9 @@ def get_field_kwargs(field_name, model_field):
|
|||
kwargs['read_only'] = True
|
||||
return kwargs
|
||||
|
||||
if model_field.has_default():
|
||||
kwargs['default'] = model_field.default
|
||||
|
||||
if model_field.has_default() or model_field.blank or model_field.null:
|
||||
kwargs['required'] = False
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user