Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用django后台任务启动后台定期任务_Python_Django - Fatal编程技术网

Python 如何使用django后台任务启动后台定期任务

Python 如何使用django后台任务启动后台定期任务,python,django,Python,Django,我想为我的SQLite文件中的检查值创建定期任务。我试图用django后台任务创建重复任务,但它不起作用。当我在cmd中使用python manage.py process\u tasks时,它工作得很好。如何使用startdjango启动此任务而不使用此命令 我在Windows 10上开发我的web应用程序 url.py from django.contrib import admin from django.urls import path, include from client impo

我想为我的
SQLite
文件中的检查值创建定期任务。我试图用django后台任务创建重复任务,但它不起作用。当我在cmd中使用
python manage.py process\u tasks
时,它工作得很好。如何使用start
django
启动此任务而不使用此命令

我在Windows 10上开发我的web应用程序

url.py

from django.contrib import admin
from django.urls import path, include
from client import tasks as task

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('client.urls')),
    path('account/', include('account.urls')),
]

task.check_groups(repeat=10, repeat_until=None)
tasks.py

from background_task import background
from django.utils import timezone
from client.models import StudyGroup, Account

@background()
def check_groups():
    check_active_groups()
    check_inactive_groups()

从文档中:

设置cron任务(或长时间运行的进程)以执行任务

您必须设置cron或其他定期运行程序来调用该命令,因为Django本身无法做到这一点