I've made a PR to update the docs: https://github.com/django/django/pull/15250
On Mon, 27 Dec 2021 at 08:13, Sergey Fursov <geyse...@gmail.com> wrote: > Please, disregard the part about failing tests, I had an old version > locally without this commit applied > https://github.com/django/django/commit/a57c783dd4e6dc73847081221827a1902eede88b > Anyway, I think it might be confusing (at least it is confusing to me) > that by default yaml serializer produces a different output than provided > in docs > > воскресенье, 26 декабря 2021 г. в 22:21:42 UTC+3, Sergey Fursov: > >> Hi there, >> >> Before opening a ticket I would like to discuss my problem here. >> >> Django docs say: >> >> ``` >> YAML¶ <https://docs.djangoproject.com/en/4.0/topics/serialization/#yaml> >> >> YAML serialization looks quite similar to JSON. The object list is >> serialized as a sequence mappings with the keys “pk”, “model” and “fields”. >> Each field is again a mapping with the key being name of the field and the >> value the value: >> - fields: {expire_date: !!timestamp '2013-01-16 08:16:59.844560+00:00'} >> model: sessions.session pk: 4b678b301dfd8a4e0dad910de3ae245b >> ``` >> https://docs.djangoproject.com/en/4.0/topics/serialization/#yaml >> >> But I cannot find a way to produce the same output. Both available to me >> environments (MacOS and Debian linux inside a Docker container) product a >> simpler output, like >> >> ``` >> >> obj = core.ModelA.objects.get(id=1) >> >> print(serializers.serialize('yaml', [obj])) >> - model: core.modela >> pk: 1 >> fields: >> created: 2017-02-05 16:11:44.310613+00:00 >> .... other fields ... >> ``` >> >> I've found this after running full Django test suite when 6 test from >> django/tests/timezones/tests.py failed. Example failure: >> >> ``` >> FAIL: test_naive_datetime_with_microsecond >> (timezones.tests.SerializationTests) >> ---------------------------------------------------------------------- >> Traceback (most recent call last): >> File "/Users/geyser/coding/opensource/django/tests/timezones/tests.py", >> line 671, in test_naive_datetime_with_microsecond >> self.assert_yaml_contains_datetime(data, "2011-09-01 13:20:30.405060") >> File "/Users/geyser/coding/opensource/django/tests/timezones/tests.py", >> line 625, in assert_yaml_contains_datetime >> self.assertRegex(yaml, r"\n fields: {dt: !(!timestamp)? '%s'}" % >> re.escape(dt)) >> AssertionError: Regex didn't match: "\\n fields: {dt: !(!timestamp)? >> '2011\\-09\\-01\\ 13:20:30\\.405060'}" not found in '- model: >> timezones.event\n pk: null\n fields:\n dt: 2011-09-01 >> 13:20:30.405060\n' >> ``` >> >> I've tried to install several different pyyaml versions (from 6.0 down to >> 5.1.2). >> >> Do I miss something or it is a valid issue for opening a ticket? >> >> Thanks, >> Sergey Fursov >> > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/6793d234-92f5-46fa-bc19-3996626dc456n%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/6793d234-92f5-46fa-bc19-3996626dc456n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM1JV95MzE0cOziaYQ17kMMDEBTCJBkTaPkphZQFqdaeiw%40mail.gmail.com.