Checking for a more specific exception when user might have passed in a list without specifying many=True.

This commit is contained in:
Gregor Müllegger 2014-11-21 08:32:53 +01:00
parent 30ce4c6413
commit 2b3d4a3783

View File

@ -163,7 +163,7 @@ class BaseSerializer(Field):
if self.instance is not None and not getattr(self, '_errors', None): if self.instance is not None and not getattr(self, '_errors', None):
try: try:
self._data = self.to_representation(self.instance) self._data = self.to_representation(self.instance)
except Exception as exc: except AttributeError as exc:
if isinstance(self.instance, (list, tuple, QuerySet)): if isinstance(self.instance, (list, tuple, QuerySet)):
msg = ( msg = (
'The reason for this exception might be that you ' 'The reason for this exception might be that you '