Skip to content

Commit b8bdf81

Browse files
committed
Merge pull request #2315 from tomchristie/yaml-encoder-fix
YAML encoder fix for 3.0 serializers.
2 parents 1e531d2 + a68d933 commit b8bdf81

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

rest_framework/utils/encoders.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.utils.encoding import force_text
88
from django.utils.functional import Promise
99
from rest_framework.compat import OrderedDict
10+
from rest_framework.utils.serializer_helpers import ReturnDict, ReturnList
1011
import datetime
1112
import decimal
1213
import types
@@ -107,14 +108,14 @@ def represent_mapping(self, tag, mapping, flow_style=None):
107108
OrderedDict,
108109
yaml.representer.SafeRepresenter.represent_dict
109110
)
110-
# SafeDumper.add_representer(
111-
# DictWithMetadata,
112-
# yaml.representer.SafeRepresenter.represent_dict
113-
# )
114-
# SafeDumper.add_representer(
115-
# OrderedDictWithMetadata,
116-
# yaml.representer.SafeRepresenter.represent_dict
117-
# )
111+
SafeDumper.add_representer(
112+
ReturnDict,
113+
yaml.representer.SafeRepresenter.represent_dict
114+
)
115+
SafeDumper.add_representer(
116+
ReturnList,
117+
yaml.representer.SafeRepresenter.represent_list
118+
)
118119
SafeDumper.add_representer(
119120
types.GeneratorType,
120121
yaml.representer.SafeRepresenter.represent_list

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy