'Django: How to make a progress bar for a function in views.py which is taking time to complete?

I am working with django to develop a UI. In the backend one function is running some ML scripts hence its taking time to return the render template. The code is as below:

home.html
<a href="engine-s">
    <button type="button" class="btn btn-primary btn-sm" title="Insight Engine" id="{{file}}"><i class="fas fa-solid fa-eye"></i></button>
</a>    

views.py
path('engine-s', views.engine_s, name='engine-s')

manage.py
def engine_s(request):
    text=get_text_from_pdf("demo_pdf_file\demo_file.pdf")
    file_to_analyze(text)
    return render(request, 'engine-s.html' )

So initialy my home page is home.html where there is a button which is initiating engine_s(request) and returning engine-s.html. But it is taking time as get_text_from_pdf function is there.

So how to show a progress bar in my home.html for my engine_s function progress until it returns new page (engine-s.html)?

Thanks.



Sources

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

Source: Stack Overflow

Solution Source