Commit a32baeab by Erick Wilder

Use datetime example for the `Field.initial` attribute

Just like regular Django fields, the example adopted uses a `datetiume.date.today` to
illustrate the functionality.
parent 908efd66
...@@ -84,10 +84,10 @@ A text string that may be used as a description of the field in HTML form fields ...@@ -84,10 +84,10 @@ A text string that may be used as a description of the field in 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 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`: you may do with any regular Django `Field`:
def user_default_color(): import datetime
return 'blue' from rest_framework import serializers
class ExampleSerializer(serializers.Serializer):
color = serializers.CharField(initial=user_default_color) day = serializers.DateField(initial=datetime.date.today)
### `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