Index: django/core/serializers/pyyaml.py =================================================================== --- django/core/serializers/pyyaml.py (revision 6021) +++ django/core/serializers/pyyaml.py (working copy) @@ -20,8 +20,14 @@ def end_serialization(self): self.options.pop('stream', None) self.options.pop('fields', None) - yaml.dump(self.objects, self.stream, **self.options) + if self.options.has_key("safe_dump") and \ + self.options.pop("safe_dump") == True: + yaml.safe_dump(self.objects, self.stream, **self.options) + else: + self.options.pop('safe_dump', None) + yaml.dump(self.objects, self.stream, **self.options) + def getvalue(self): return self.stream.getvalue() Index: docs/serialization.txt =================================================================== --- docs/serialization.txt (revision 6021) +++ docs/serialization.txt (working copy) @@ -135,6 +135,21 @@ json_serializer = serializers.get_serializer("json")() json_serializer.serialize(queryset, ensure_ascii=False, stream=response) +yaml +~~~~ + +If want dump complex data that will be used by non python clients you +want to use ``safe_dump=True`` as a parameter to the ``serialize()`` +call. Otherwise UTF-8 strings will end up as type "!!python/unicode". +Using a large width solves problems with some parsers, too. + +For example:: + + yaml_serializer = serializers.get_serializer("json")() + yaml_serializer.serialize(queryset, safe_dump=True, +stream=response, width=9999999999) + + Writing custom serializers ``````````````````````````