Is it possible to submit a django form to run 2-3 large tasks at the backend and display the user a page for status/progress of the tasks running and display the output on completion.
I have a function as below in my view.py file which executes large tasks. I want that while the tasks are been running in the back-end on my server(ubuntu), instead of showing the user with the page/browser loading (which hangs for huge tasks), I want to show a page to show the tasks status/progress.
views.py
def test(request) :
if request.method == 'POST': # If the form has been submitted...
form = TestForm(request.POST)
if form.is_valid(): # All validation rules pass
form_data = form.cleaned_data
## Get the form data and use it
output, error = executeCommand("##Perform the required action with the form data")
if error == '' :
return HttpResponse('Work Done !! Thanks')
else :
return HttpResponse('Error Occurred')
else:
form = TesForm() # An unbound form
return render_to_response("test.html", { 'form' : form } , context_instance=RequestContext(request))
Any help/advice is greatly appreciated.
I think your webserver will get stucked if your "executeCommand" take very long time to finish.
You might use message queues as suggested by toabi.
You might have a look on django-celery.