can I have multiple model urls called in sequence for a single request #8601
-
I want to build some reusable model services that can be shared across multiple different requests. Can I have multiple model service URLs called in sequence for a single request? Let's say I have a model service for a request coming from a form in the view. I define the model for that form and the table to support it. But I want to have a shared service that pre-processes that request and applies some business logic before calling the main model service. Then after the main model service saves to the database I want another shared service to do some post-processing before returning the response to the view. Is this possible and is the Custom router where I can do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The solution is to create your own middleware and let it have access to incoming requests. Suggest you filter on the incoming request url so your code only affects that flow. See https://docs.djangoproject.com/en/4.1/topics/http/middleware/#:~:text=Middleware%20is%20a%20framework%20of,for%20doing%20some%20specific%20function. |
Beta Was this translation helpful? Give feedback.
The solution is to create your own middleware and let it have access to incoming requests. Suggest you filter on the incoming request url so your code only affects that flow. See https://docs.djangoproject.com/en/4.1/topics/http/middleware/#:~:text=Middleware%20is%20a%20framework%20of,for%20doing%20some%20specific%20function.