Y
Y
Yuri2022-04-18 14:43:00
Django
Yuri, 2022-04-18 14:43:00

How to run a function in Django background?

There is a view

def view_index(request,*args,**kwargs):
    run_very_long_function(args) // эту функцию надо выполнить в фоне, чтобы рендер произошел до ее выполнения
    return render(request,"template.html")


the question is: how to run run_very_long_function(args) so that the render happens immediately without waiting for its execution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Golovanenko, 2022-04-18
@drygdryg

You can use Django-RQ or Celery to create a task from a function and queue it up.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question