Отобразите ответ в задании сельдерея с django - PullRequest
0 голосов
/ 18 апреля 2020

В моих взглядах:

 def start(request, pk):
            group = Group.objects.get(pk=pk)
            print(group.start.hour)
            print(group.start.minute)
            print(datetime.datetime.now().hour)
            print(datetime.datetime.now().minute)
            now = datetime.datetime.now()
            print(now)
            then = now + datetime.timedelta(hours=group.start.hour, minutes=group.start.minute)
            print(then)
            # greeting_task.apply_async(args=[group.pk], eta=then)
            hello.apply_async((group.pk,), countdown=30)

            #
            # while True:
            #     if group.start.hour==datetime.datetime.now().hour and group.start.minute==datetime.datetime.now().minute:
            #         break
            # return render(request, 'game/game.html', {'group': group})
            return HttpResponse('wait for several minutes')

Здесь я назвал задачу сельдерея с aplly_async()

в моих задачах:

@shared_task
def hello(request, pk):
    group = Group.objects.get(pk=pk)
    return render(request, 'game/game.html', {'group':group})

Здесь ответ рендеринга не работает, как я могу это сделать? Есть ли другие способы сделать это? Основная цель: мне нужно открыть определенную страницу через определенное время, например, здесь, через 30 секунд, она должна отобразить другую страницу!

...