Merge pull request #1757 from jwhitlock/error_as_list

ModelSerializer.restore_object - wrap ValueError error in a list
This commit is contained in:
Tom Christie 2014-08-14 14:29:28 +01:00
commit f23b500fba
2 changed files with 2 additions and 2 deletions

View File

@ -977,7 +977,7 @@ class ModelSerializer(Serializer):
try:
setattr(instance, key, val)
except ValueError:
self._errors[key] = self.error_messages['required']
self._errors[key] = [self.error_messages['required']]
# Any relations that cannot be set until we've
# saved the model get hidden away on these

View File

@ -685,7 +685,7 @@ class ModelValidationTests(TestCase):
photo_serializer = PhotoSerializer(instance=photo, data={'album': ''}, partial=True)
self.assertFalse(photo_serializer.is_valid())
self.assertTrue('album' in photo_serializer.errors)
self.assertEqual(photo_serializer.errors['album'], photo_serializer.error_messages['required'])
self.assertEqual(photo_serializer.errors['album'], [photo_serializer.error_messages['required']])
def test_foreign_key_with_partial(self):
"""