Tuesday, 15 March 2011

python - DRF3 M2M nested serializer removing nested 'id' fields on update() -


I am trying to create a full featured M2M (via table) nested serializer, which () Works right on. However, when I withdraw JSON from the GET version of the serializer which contains the nested records ID and put against the same serializer, the 'id' field is removed from the nested record validated_data until that time when it is received Happens (update) method

  {"id": 1, "address": [{"id": 1, #) This "city" has been disconnected: "Oakville", "Eder": "88 "City": "Water", "Adrer": "88 Main St.", "Postcode": "01101"}, "postal_code": "01101"}, {"id": 2, # this "city" has been deducted: "01101 "}," Customer_number ": 1234," customer_type ": 1," pricing ": 2," name ":" customer number 1234 "}  

Any ideas?

Yes this is a duplicate

I think I have understood it like that The ModelSerializer appears to be the only 'id' field to read by default. The solution is to add a specific 'id' field to the serializer. See Tomchristie's comment


No comments:

Post a Comment