Hi folks,
I had this issue recently where I had a writeable serializer nesting User info under the key 'owner', that was passing validation (because it contained the owner related data) but then removing the entire owner field from the validated data. This would get passed up to my update method which would hang because it was expecting to find owner data to play with. This was happening when I was using FormData objects on the client side, and it was perplexing because it wasn't happening if I used json instead.
Turns out it was caused by get_value() method on the nested serializer which would call the utils.html.parse_html_dict function when it gets a QueryDict objects (as it does when it handles FormData). This is turn does a regex match between the submitted keys in the FormData and the field names. If it finds no match between a key and a field it returns empty. The regex specifies that to match, the key which is used to represent nested data must include a full_stop character. So in my case the keys of nested data should look something like: 'owner.email'. But because all I had included was a key: 'owner'. The regex never found a match.
No big deal - as I now know what I should be doing. But I'm just wondering if this convention for nested data in FormData objects is documented in the api docs? I've spent quite a lot of time looking for it - but couldn't find anything. But apologies if I missed it. Or is this just a standard convention for getting around the limits of form nesting in html5? My googling on that topic is that lots of folk do lots of very different things.
Also - I'm wondering if it's ideal that the serializer should be able to pass validation in this instance?
Thanks for your time :)