I solved a similar problem using Celery, something like this.
def start_long_process_view(request, pk): task = do_long_processing_stuff.delay() return HttpResponse(f'{"task":"{task.id}"}')
Then you can have a second view that can check the status of the task.
from celery.result import AsyncResult def check_long_process(request, task_id): result = AsyncResult(task_id) return HttpResponse(f'{"state":"{result.state}"')
Finally, using javascript, you can simply get the status right after the task starts. Updating every half second will be more than enough to give your users good feedback.
If you think there are a lot of Celery, there are light alternatives that will work just fine: https://djangopackages.org/grids/g/workers-queues-tasks/
Mario césar
source share