Hi everyone!
I want to create an endpoint that calls a 3rd party API, gets the data, does some quick modification(doesn’t really matter what) and returns them as JSON.
The problem is that if the user decides to leave the current URL and sends a new request for a different view to render a new template, while the data are being downloaded, the new template doesn’t get loaded.
From my understanding this happens because I am blocking the main thread when calling the API, so when the new request comes through, Django cannot respond to that since it’s still processing the initial request to the external API.
I did some research about this and Celery seems like a common solution to this, however I don’t think it solves my exact problem since the goal is not to start a background task and forget about it, but rather get the results and send them to the client.
Is there another solution like Celery or is my approach wrong here?