how to use django-background-tasks

前端 未结 4 1279
离开以前
离开以前 2020-12-30 14:39

I am making a django application. To calculate the rank of the feeds based on lines and comment, I am trying to use django-background-tasks. the function I am using in nodes

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 15:21

    You should run python manage.py process_tasks as described here. You can add it to crontab to execute periodically.

    UPD:

    1. You don't need to run process_tasks using crontab cause this command internally sleeps every 5 seconds (this value is configurable) and then again checks whether there is any task to run.
    2. Your task looks strange. You should declare it as global function in separate file and pass id of model inside it, fetch object by id do calculations and save your object.

提交回复
热议问题