The easiest way to solve this problem is to write your own parser that parses an incoming multi-page request. I used formencode to do the actual parsing, but you can use any formdata nested library. This requires surprisingly little code:
from rest_framework import parsers from formencode.variabledecode import variable_decode class MultipartFormencodeParser(parsers.MultiPartParser): def parse(self, stream, media_type=None, parser_context=None): result = super().parse( stream, media_type=media_type, parser_context=parser_context ) data = variable_decode(result.data) return parsers.DataAndFiles(data, result.files)
And then in the ViewSet
class ImageViewSet(viewsets.ModelViewSet): ... parsers = (MultipartFormencodeParser,) ...
Formencode represents lists as <key>-<index> entries in encoded form data and nested properties as <item>.<proprety> . Thus, in your example, the client will need to code the annotations as something like "annotation-1.name" in the request. Obviously, you still have to handle updating the embedded data manually in the serializer, as indicated in the documentation for the rest of the structure here
source share