#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:
Erick Wilder 2016-02-17 11:01:09 +01:00
parent 8109752061
commit 908efd6656

View File

@ -81,7 +81,13 @@ A text string that may be used as a description of the field in HTML form fields
### `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`