0

I tried to run the background task code in Django. its working fine but interval time is not working. it working every second how to fix it anyone gives some solution.

views.py

from django.shortcuts import render
from django.http import HttpResponse
from background_task import background
from django.core.mail import send_mail

@background(schedule=5)
def hello():
    print('hello_world')

# Create your views here.
def index(request):
    hello()
    return HttpResponse('<h1> Hello World </h1>') 

I tried to pass repeat parameter also

from django.shortcuts import render
from django.http import HttpResponse
from background_task import background
from django.core.mail import send_mail

@background(schedule=5)
def hello():
    print('hello_world')

# Create your views here.
def index(request):
    hello(repeat=10)
    return HttpResponse('<h1> Hello World </h1>') 

I tried many ways. But still is not working.I need every One hour to print hello world.

hari prasanth
  • 716
  • 1
  • 15
  • 35

0 Answers0