aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGitHub Merge Button2011-07-04 01:36:29 -0700
committerGitHub Merge Button2011-07-04 01:36:29 -0700
commit4887ac949573b33a0d1176bb0a6cf83802a2b607 (patch)
tree0548a9b64b384f08e150ff194028f6844ae38660
parent2dc042f0cf3a3d6049a1d2641d99b9e10f691b35 (diff)
parent3161475562c3a529389657f21813f91864b0787a (diff)
downloaddjango-rest-framework-4887ac949573b33a0d1176bb0a6cf83802a2b607.tar.bz2
Merge 3161475562c3a529389657f21813f91864b0787a into 2dc042f0cf3a3d6049a1d2641d99b9e10f691b35
-rw-r--r--djangorestframework/serializer.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/djangorestframework/serializer.py b/djangorestframework/serializer.py
index 82aeb53f..88ea12d8 100644
--- a/djangorestframework/serializer.py
+++ b/djangorestframework/serializer.py
@@ -177,7 +177,7 @@ class Serializer(object):
Keys serialize to their string value,
unless they exist in the `rename` dict.
"""
- return getattr(self.rename, smart_str(key), smart_str(key))
+ return self.rename.get(smart_str(key), smart_str(key))
def serialize_val(self, key, obj):
@@ -228,7 +228,10 @@ class Serializer(object):
# serialize each required field
for fname in fields:
- if hasattr(self, smart_str(fname)):
+ if fname in instance:
+ # finally check for a key 'fname' on the instance
+ obj = instance[fname]
+ elif hasattr(self, smart_str(fname)):
# check for a method 'fname' on self first
meth = getattr(self, fname)
if inspect.ismethod(meth) and len(inspect.getargspec(meth)[0]) == 2:
@@ -236,9 +239,6 @@ class Serializer(object):
elif hasattr(instance, smart_str(fname)):
# now check for an attribute 'fname' on the instance
obj = getattr(instance, fname)
- elif fname in instance:
- # finally check for a key 'fname' on the instance
- obj = instance[fname]
else:
continue