Commit 908efd66 by Erick Wilder

#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.
parent 81097520
...@@ -81,7 +81,13 @@ A text string that may be used as a description of the field in HTML form fields ...@@ -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`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment