Signal django to run a task

后端 未结 2 970
离开以前
离开以前 2020-12-06 23:32

I made a management command that populates one of my models from a csv file.
I need to do this update quite frequently and the csv files have tens of thousands of lines.

2条回答
  •  清歌不尽
    2020-12-06 23:58

    You can do the same with Django Background Task. Its a databased-backed work queue for Django. And is easy to implement than Celery.

    from background_task import background
    @background(schedule=60)
    def your_task():
        # do your cool work here.
    

    This will convert the your_task into a background task function. When you call it from regular code it will actually create a Task object and stores it in the database.

提交回复
热议问题