From 8fbf8c3fa3d3d62389565887de32c9d3bfa16eaa Mon Sep 17 00:00:00 2001 From: linchiwei123 <40888469+linchiwei123@users.noreply.github.com> Date: Fri, 5 Jul 2019 16:11:20 +0800 Subject: [PATCH] Update serializers.md (#6783) --- docs/api-guide/serializers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 0bc90b40a..370e89860 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -966,6 +966,7 @@ The following class is an example of a generic serializer that can handle coerci into primitive representations. """ def to_representation(self, obj): + output = {} for attribute_name in dir(obj): attribute = getattr(obj, attribute_name) if attribute_name.startswith('_'): @@ -991,6 +992,7 @@ The following class is an example of a generic serializer that can handle coerci else: # Force anything else to its string representation. output[attribute_name] = str(attribute) + return outout ---