mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 16:24:18 +03:00
Update serializers.md (#6783)
This commit is contained in:
parent
976739206c
commit
8fbf8c3fa3
|
@ -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
|
||||
|
||||
---
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user