Le 06/03/17 à 15:44, Brice PARENT a écrit :
> Le 06/03/17 à 14:28, Adam Johnson a écrit :
>> PyYAML sorts keys by default, so if you use the YAML serializer that
>> should work for your usecase.
> I think it will become my new default !
It appears that the rendered format is not very consistent, or at least
it's what I've found. Yaml seems to offer a short and a long syntax.
I tried with 2 models, one from stock Django (flatpages), which seems to
give something that corresponds to my needs, and one with a custom one,
where the used syntax doesn't create a new line for each field. (I
edited the outputs to focus on the idea and remove irrelevant contents).
./manage.py dumpdata --format yaml --indent 4 flatpages
- fields:
content: '<p>First line.</p>
<p>Second line</p>'
enable_comments: false
registration_required: false
sites: [1]
template_name: ''
title: Multiline
url: /my/test/
model: flatpages.flatpage
pk: 13
./manage.py dumpdata --format yaml --indent 4 myapp
- fields: {content: "<p>First line.</p>\r\n\r\n<h3>Second line</h3>\r\
\n", module: 1, position: 1, summary: "<h3>First line.</h3>\r\
\n\r\n<h3>Second line</h3>\r\", title: "My title"}
model: myapp.mymodel
pk: 1
So with the same command, I've gotten two formats, one that is
git-friendly, and one that isn't. I haven't yet looked at the source
code on why it chose to use one syntax over the other though.
Brice