mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-03 19:00:17 +03:00
#3937 Update docs for the Field.initial attribute.
Add an usage example on how to pass a callable to the `Field.initial` in the docs.
This commit is contained in:
parent
8109752061
commit
908efd6656
|
@ -81,7 +81,13 @@ A text string that may be used as a description of the field in HTML form fields
|
||||||
|
|
||||||
### `initial`
|
### `initial`
|
||||||
|
|
||||||
A value that should be used for pre-populating the value of HTML form fields.
|
A value that should be used for pre-populating the value of HTML form fields. You may pass a callable to it, just as
|
||||||
|
you may do with any regular Django `Field`:
|
||||||
|
|
||||||
|
def user_default_color():
|
||||||
|
return 'blue'
|
||||||
|
|
||||||
|
color = serializers.CharField(initial=user_default_color)
|
||||||
|
|
||||||
### `style`
|
### `style`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user