'How can I break up a Django request into multiple requests?

I wanna do the following inside a Django REST ModelViewSet:

  1. receive data from an HTTP POST request
  2. break the data into several pieces
  3. pass the pieces to different ViewSets that should handle authentication, etc. based on the original request

Background is the following:

I have a working REST implementation with normal ModelViewSets for all endpoints and now I'm implementing a syncing protocol for a Progressive Web App that should work completely offline.

The idea is that the normal ViewSets keep working and I implement the custom logic only once in the ViewSets. But I want to be able to collect request data offline and send all at once (also to guarantee order). Then the "sync" endpoint breaks the data apart and passes it to the respective views. I'm only missing a copy of the request object with adjusted data...

What I tried to far:

  • deepcopy of the request object does not work
  • I have a hard time figuring out how to construct a request from scratch that mimics the original


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source