I have a question, that can Django do multi-thread works?
Here is what I want to do: click a button on a web page, then there are some functions in model.py starts
If you don't want to add some overkill framework to your project, you can simply use subprocess.Popen:
def my_command(request):
command = '/my/command/to/run' # Can even be 'python manage.py somecommand'
subprocess.Popen(command, shell=True)
command = '/other/command/to/run'
subprocess.Popen(command, shell=True)
return HttpResponse(status=204)
[edit] As mentioned in the comments, this will not start a background task and return the HttpResponse right away. It will execute both commands in parallel, and then return the HttpResponse once both are complete. Which is what OP asked.