Reputation: 236
I want to create periodic task for check values in my SQLite
file. I tried to create repeating task with django-background-tasks but it doesn't work. It works fine when I used python manage.py process_tasks
in cmd. How start this task with start django
and without use this command?
I develop my web app on 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()
Upvotes: 2
Views: 854
Reputation: 3953
From the docs:
setup a cron task (or long running process) to execute the tasks
You have to setup cron or some other periodic runner to call that command because Django by itself will not be able to do this.
Upvotes: 1