【发布时间】:2020-01-10 05:11:22
【问题描述】:
我想为我的SQLite 文件中的检查值创建定期任务。我尝试使用 django-background-tasks 创建重复任务,但它不起作用。当我在 cmd 中使用 python manage.py process_tasks 时,它工作正常。如何使用 start django 启动此任务而不使用此命令?
我在 Windows 10 上开发我的网络应用程序。
urls.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()
【问题讨论】: