#37023: Make XML serializer put each ManyToManyField object on its own line
-------------------------------------+-------------------------------------
               Reporter:  Tim        |          Owner:  Tim Graham
  Graham                             |
                   Type:             |         Status:  assigned
  Cleanup/optimization               |
              Component:  Core       |        Version:  dev
  (Serialization)                    |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 The XML serializer serializes many-to-many relations on a single line:

 `<field name="categories" rel="ManyToManyRel"
 to="serializers.category"><object pk="1"></object><object
 pk="2"></object></field>`

 which isn't very readable. I suggest this format instead:

 {{{
 <field name="categories" rel="ManyToManyRel" to="serializers.category">
   <object pk="1"></object>
   <object pk="2"></object>
 </field>
 }}}

 Although not strictly required for this ticket, the first commit in my PR
 will remove fixed values in the XML serializer's `indent()` calls (e.g.
 `self.indent(1)`) which are unfriendly to "nested fields" like Django
 MongoDB Backend's EmbeddedModelField which I'd like to serialize like
 this:
 {{{
 <django-objects version="1.0">
   <object model="serialization_.book">
     <field name="name" type="CharField">Hamlet</field>
     <field name="author" type="EmbeddedModelField">
       <object model="serialization_.author">
         <field name="id" type="ObjectIdAutoField"><None></None></field>
         <field name="name" type="CharField">Shakespeare</field>
         <field name="age" type="IntegerField">55</field>
         <field name="address" type="EmbeddedModelField">
           <object model="serialization_.address">
             <field name="id"
 type="ObjectIdAutoField"><None></None></field>
             <field name="city" type="CharField">NYC</field>
             <field name="state" type="CharField">NY</field>
             <field name="zip_code"
 type="IntegerField"><None></None></field>
           </object>
         </field>
       </object>
      </field>
   </object>
 </django-objects>
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37023>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d5a9c4566-668ec399-cc62-480d-97a8-8b94ba882e30-000000%40eu-central-1.amazonses.com.

Reply via email to