mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Fix example in serializers.md
This commit is contained in:
parent
a1b35bb44b
commit
31021ce717
|
@ -209,13 +209,13 @@ To do any other validation that requires access to multiple fields, add a method
|
|||
start = serializers.DateTimeField()
|
||||
finish = serializers.DateTimeField()
|
||||
|
||||
def validate(self, data):
|
||||
def validate(self, attrs):
|
||||
"""
|
||||
Check that start is before finish.
|
||||
"""
|
||||
if data['start'] > data['finish']:
|
||||
if attrs['start'] > attrs['finish']:
|
||||
raise serializers.ValidationError("finish must occur after start")
|
||||
return data
|
||||
return attrs
|
||||
|
||||
#### Validators
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user