From 72d4588b5e3c72067502bbf7a71863edac350148 Mon Sep 17 00:00:00 2001 From: Sharat M R Date: Tue, 10 Oct 2017 13:24:36 +0530 Subject: [PATCH] Fix for resolving source when accessing sub-attr eg b.c --- rest_framework_json_api/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rest_framework_json_api/utils.py b/rest_framework_json_api/utils.py index 8e328883..2f1d329a 100644 --- a/rest_framework_json_api/utils.py +++ b/rest_framework_json_api/utils.py @@ -3,6 +3,7 @@ """ import copy import inspect +import operator import warnings from collections import OrderedDict @@ -339,7 +340,7 @@ def get_included_serializers(serializer): def get_relation_instance(resource_instance, source, serializer): try: - relation_instance = getattr(resource_instance, source) + relation_instance = operator.attrgetter(source)(resource_instance) except AttributeError: # if the field is not defined on the model then we check the serializer # and if no value is there we skip over the field completely