From 2d755ead3c7e84c19d1466bf7c1161f9a974b439 Mon Sep 17 00:00:00 2001 From: radams Date: Wed, 21 Oct 2015 18:01:56 -0400 Subject: [PATCH] These should either be function calls ala self.errors() I think, or what I have here which is self._errors. This fixes annoying bugs that got introduced in 3.1 to 3.2 that would cause 400 errors on invalid requests to become mysterious 500 errors. --- rest_framework/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 35fb8fcf0..a91652000 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -157,7 +157,7 @@ class BaseSerializer(Field): 'You must call `.is_valid()` before calling `.save()`.' ) - assert not self.errors, ( + assert not self._errors, ( 'You cannot call `.save()` on a serializer with invalid data.' ) @@ -218,7 +218,7 @@ class BaseSerializer(Field): self._errors = {} if self._errors and raise_exception: - raise ValidationError(self.errors) + raise ValidationError(self._errors) return not bool(self._errors)