Commit c124585d by Tom Christie

Merge pull request #219 from scfarley/related-serializers-2

Pass request to related serializers
parents 9dbaac31 1b49c5e3
...@@ -179,7 +179,8 @@ class Serializer(object): ...@@ -179,7 +179,8 @@ class Serializer(object):
stack = self.stack[:] stack = self.stack[:]
stack.append(obj) stack.append(obj)
return related_serializer(depth=depth, stack=stack).serialize(obj) return related_serializer(depth=depth, stack=stack).serialize(
obj, request=self.request)
def serialize_max_depth(self, obj): def serialize_max_depth(self, obj):
""" """
...@@ -253,11 +254,15 @@ class Serializer(object): ...@@ -253,11 +254,15 @@ class Serializer(object):
""" """
return smart_unicode(obj, strings_only=True) return smart_unicode(obj, strings_only=True)
def serialize(self, obj): def serialize(self, obj, request=None):
""" """
Convert any object into a serializable representation. Convert any object into a serializable representation.
""" """
# Request from related serializer.
if request is not None:
self.request = request
if isinstance(obj, (dict, models.Model)): if isinstance(obj, (dict, models.Model)):
# Model instances & dictionaries # Model instances & dictionaries
return self.serialize_model(obj) return self.serialize_model(obj)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment