일정 패키지를 사용하여 장고에서 작업을 예약하는 방법을 배우려고합니다. 내보기에 추가 한 코드는 다음과 같습니다. 나는 인덱스 뷰에서 스케줄러를 실행할 필요가 있다는 것을 언급해야한다. 코드 로직에 문제가 있으며 스케쥴러 만 렌더링하고 루프에 함정을 잡을 것이다. 어떻게 말해 줄 수 있는가? 그걸 써?일정 패키지를 사용하여 장고에서 작업 예약
def job():
print "this is scheduled job", str(datetime.now())
def index(request):
schedule.every(10).second.do(job())
while True:
schedule.run_pending()
time.sleep(1)
objs= objsdb.objects.all()
template = loader.get_template('objtest/index.html')
context= { 'objs': objs}
return HttpResponse(template.render(context, request))