I am using Django 1.11. I want to use the scheduler in my application to run my script once in a day.
This is my view.py file
from __future__ import print_function
from django.shortcuts import render
from django.utils import timezone
from django.http import HttpResponse
from datetime import datetime, timedelta
import requests
import schedule
import time
def republic(request):
return HttpResponse("<h1>Success Hindustan</h1>")
def indiatv(request):
return HttpResponse("<h1>Success Hindustan</h1>")
def ndtv(request):
return HttpResponse("<h1>Success NDTV</h1>")
schedule.every().day.at("17:19").do(republic(requests))
schedule.every().day.at("17:19").do(indiatv(requests))
schedule.every().day.at("17:19").do(ndtv(requests))
while 1:
schedule.run_pending()
time.sleep(1)
When I run the server I am getting following error
File "/home/imsaiful/PiroProject/pironews/feed/urls.py", line 2, in <module>
from . import views
File "/home/imsaiful/PiroProject/pironews/feed/views.py", line 230, in <module>
schedule.every().day.at("17:19").do(republic(requests))
File "/home/imsaiful/anaconda3/lib/python3.6/site-packages/schedule/__init__.py", line 385, in do
self.job_func = functools.partial(job_func, *args, **kwargs)
TypeError: the first argument must be callable
But when I remove the scheduler lines then the application running properly.