Answer the question
In order to leave comments, you need to log in
How to asynchronously pass the value of a variable from view to template?
Django.
There is a view (view1) in which the application can be considered anything for a long time, there is a calculation_progress variable. Requires the updated progress variable to be passed asynchronously to the browser.
I wrote a new view (view2) for this, so that it can be accessed from the browser with ajax for progress. But it's not clear how to take the progress variable updated in view1 from view2?
Answer the question
In order to leave comments, you need to log in
Theoretical side:
There is one (suitable) technology for transferring events from the server to the client - this is WebSocket.
And there are a bunch of old crutches that were relevant before the advent of WebSocket - these are Commet , Long Polling , Server Push , and other techniques based on a mockery of the HTTP protocol that was not intended for this.
Look towards Django Channels .
For heavy computations and any (potentially) long running processes, asynchronous background task queues are supposed to be used:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question