diff --git a/rest_framework/fields.py b/rest_framework/fields.py index c0253f86b..d7f650f04 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -10,6 +10,7 @@ import datetime import inspect import re import warnings +import collections from decimal import Decimal, DecimalException from django import forms from django.core import validators @@ -52,8 +53,8 @@ def get_component(obj, attr_name): Given an object, and an attribute name, return that attribute on the object. """ - if isinstance(obj, dict): - val = obj.get(attr_name) + if isinstance(obj, collections.Mapping): + val = obj[attr_name] else: val = getattr(obj, attr_name)