mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-18 04:02:35 +03:00
added notes regarding default value propagation from model to serializer field
This commit is contained in:
parent
728fdbe13c
commit
2cc065f9f7
|
@ -68,6 +68,15 @@ When serializing the instance, default will be used if the object attribute or d
|
|||
|
||||
Note that setting a `default` value implies that the field is not required. Including both the `default` and `required` keyword arguments is invalid and will raise an error.
|
||||
|
||||
Notes Regarding default value propagation from model to serializer:
|
||||
|
||||
all the default values of model will be pass as default to serializer and to the options method.
|
||||
|
||||
if the default is callable then it is propagated in serializer which is evaluated at each time but
|
||||
not in options method.
|
||||
|
||||
if the value for given field is not given then default value will be present in serializer also avaliable in serializer's methods.Specified validation on given field will be evaluted on default value as that field will be present in serializer.
|
||||
|
||||
### `allow_null`
|
||||
|
||||
Normally an error will be raised if `None` is passed to a serializer field. Set this keyword argument to `True` if `None` should be considered a valid value.
|
||||
|
|
Loading…
Reference in New Issue
Block a user