mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-22 18:12:12 +03:00
Merge pull request #2140 from sicarrots/fix_get_component
Fixed get_component method in Field to get working with subclassess of collections.Mapping
This commit is contained in:
commit
67ae6b2552
|
@ -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,7 +53,7 @@ def get_component(obj, attr_name):
|
|||
Given an object, and an attribute name,
|
||||
return that attribute on the object.
|
||||
"""
|
||||
if isinstance(obj, dict):
|
||||
if isinstance(obj, collections.Mapping):
|
||||
val = obj.get(attr_name)
|
||||
else:
|
||||
val = getattr(obj, attr_name)
|
||||
|
|
Loading…
Reference in New Issue
Block a user