Skip to content

Commit 8fbf8c3

Browse files
linchiwei123lovelydinosaur
authored andcommitted
Update serializers.md (#6783)
1 parent 9767392 commit 8fbf8c3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/api-guide/serializers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ The following class is an example of a generic serializer that can handle coerci
966966
into primitive representations.
967967
"""
968968
def to_representation(self, obj):
969+
output = {}
969970
for attribute_name in dir(obj):
970971
attribute = getattr(obj, attribute_name)
971972
if attribute_name.startswith('_'):
@@ -991,6 +992,7 @@ The following class is an example of a generic serializer that can handle coerci
991992
else:
992993
# Force anything else to its string representation.
993994
output[attribute_name] = str(attribute)
995+
return outout
994996

995997
---
996998

0 commit comments

Comments
 (0)