mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
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:
parent
908efd6656
commit
a32baeab0c
|
@ -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`
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user