Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api-guide/serializers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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('_'):
Expand All @@ -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

---

Expand Down