I am new to Django and the django-background-tasks package.
I am facing an issue that I couldn't do/start background task unless I forcefully run the command process_tasks , that is python manage.py process_tasks. I want to do/start background task without run the process_tasks command.
settings.py
MAX_ATTEMPTS=1
BACKGROUND_TASK_RUN_ASYNC = True
tasks.py
from background_task import background
#included necessary packages for SMTP
@background(schedule=5)
def test():
#send mail to some ids
views.py
def index(request):
test(schedule=5)
return HttpResponse("Hello, world. ")
Ignore my logic.
That is how django-background-tasks works. You have to run that process for the task runner to start processing tasks.
https://github.com/arteria/django-background-tasks#running-tasks