-2

I need help with the following problem.

I am working on a Django site. My page requires users to complete a form. My view then processes this form information. Part of this involves processing large files which takes a long time. I want to be able to return a thank-you page as soon as the form is submitted but then process the data afterwards in the same view. How can I do this?

robert
  • 141
  • 6

1 Answers1

0

One solution would be, once the form has been submitted, delegate the processing of the forms data to a separate thread. This will allow you to then redirect the user to the thank you page whilst the processing happens in the background.

This stack overflow question on background threads in python gives a quick introduction into a simple way of accomplishing this. Also, this article on background task processing and deferred execution in Django introduces a more sophisticated approach.

Community
  • 1
  • 1
robjohncox
  • 3,639
  • 3
  • 25
  • 51