I need to use my middleware to be able to modify an incoming POST form-data body enroute to the database.
Before I get a storm of “you don’t do it that way, use a class method in the model, view or serializer” yes I know but I have my reasons.
In my middleware I have one case where the body comes in as follows:
request_post_params= <QueryDict: {'csrfmiddlewaretoken': ['yTAkZ50ecwj1XyzDF2a4RNA8vKKChzDHjeZ85GeM1Qf8pmLhsDAHhVKRXHHqMmuA'], 'matchingKey': ['test'], 'sequence': ['1'], 'param_kwargs_json': ['null'], 'param1': ["poopoo='shite'"], 'param2': ['N/A'], 'param3': ['N/A'], 'param4': ['N/A'], 'param5': ['N/A'], 'param6': ['N/A'], 'param7': ['N/A'], 'param8': ['N/A'], 'param9': ['N/A'], 'param10': ['N/A'], 'description': ['N/A'], '_save': ['Save']}>
The QueryDict is accessible and I can make a local copy, edit the Dict and add my data in ‘param2’ but trying to put it back into the request is the first place I need help.
The other cases include the POST body as a byte string with a multipart form-data with a boundary.
What class handles the multipart form-data with boundaries as it goes into the db? If i could look at that I think I can figure out how to convert it into a dict, make my changes and put it back.