Merge pull request #2115 from hgiasac/master

Fix typo "serailizers" to  "serializers"
This commit is contained in:
Tom Christie 2014-11-23 19:59:06 +00:00
commit 5cad60dc4f

View File

@ -189,13 +189,13 @@ You can either return `non_field_errors` from the validate method by raising a s
def validate(self, attrs):
# serializer.errors == {'non_field_errors': ['A non field error']}
raise serailizers.ValidationError('A non field error')
raise serializers.ValidationError('A non field error')
Alternatively if you want the errors to be against a specific field, use a dictionary of when instantiating the `ValidationError`, like so:
def validate(self, attrs):
# serializer.errors == {'my_field': ['A field error']}
raise serailizers.ValidationError({'my_field': 'A field error'})
raise serializers.ValidationError({'my_field': 'A field error'})
This ensures you can still write validation that compares all the input fields, but that marks the error against a particular field.