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.
This commit is contained in:
Erick Wilder 2016-02-19 09:53:40 +01:00
parent 908efd6656
commit a32baeab0c

View File

@ -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
you may do with any regular Django `Field`:
def user_default_color():
return 'blue'
color = serializers.CharField(initial=user_default_color)
import datetime
from rest_framework import serializers
class ExampleSerializer(serializers.Serializer):
day = serializers.DateField(initial=datetime.date.today)
### `style`