From 54096dc22f255140f148906e85da5e4be0048f10 Mon Sep 17 00:00:00 2001 From: Corentin Smith Date: Thu, 4 Aug 2016 23:06:35 +0200 Subject: [PATCH] Add imports in validators docs (#4355) --- docs/api-guide/validators.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/api-guide/validators.md b/docs/api-guide/validators.md index a059f1197..f04c74c3c 100644 --- a/docs/api-guide/validators.md +++ b/docs/api-guide/validators.md @@ -64,6 +64,8 @@ It takes a single required argument, and an optional `messages` argument: This validator should be applied to *serializer fields*, like so: + from rest_framework.validators import UniqueValidator + slug = SlugField( max_length=100, validators=[UniqueValidator(queryset=BlogPost.objects.all())] @@ -80,6 +82,8 @@ It has two required arguments, and a single optional `messages` argument: The validator should be applied to *serializer classes*, like so: + from rest_framework.validators import UniqueTogetherValidator + class ExampleSerializer(serializers.Serializer): # ... class Meta: @@ -114,6 +118,8 @@ These validators can be used to enforce the `unique_for_date`, `unique_for_month The validator should be applied to *serializer classes*, like so: + from rest_framework.validators import UniqueForYearValidator + class ExampleSerializer(serializers.Serializer): # ... class Meta: @@ -183,7 +189,7 @@ It takes a single argument, which is the default value or callable that should b created_at = serializers.DateTimeField( read_only=True, - default=CreateOnlyDefault(timezone.now) + default=serializers.CreateOnlyDefault(timezone.now) ) ---