File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1515from rest_framework .exceptions import ValidationError
1616from rest_framework .settings import api_settings
1717from rest_framework .utils import html , representation , humanize_datetime
18+ import collections
1819import copy
1920import datetime
2021import decimal
@@ -60,14 +61,12 @@ def get_attribute(instance, attrs):
6061 # Break out early if we get `None` at any point in a nested lookup.
6162 return None
6263 try :
63- instance = getattr (instance , attr )
64+ if isinstance (instance , collections .Mapping ):
65+ instance = instance [attr ]
66+ else :
67+ instance = getattr (instance , attr )
6468 except ObjectDoesNotExist :
6569 return None
66- except AttributeError as exc :
67- try :
68- return instance [attr ]
69- except (KeyError , TypeError , AttributeError ):
70- raise exc
7170 if is_simple_callable (instance ):
7271 instance = instance ()
7372 return instance
You can’t perform that action at this time.
0 commit comments