i looked at celery documentation and trying something from it but it not work like the example. maybe i'm wrong at some point, please give me some pointer if i'm wrong about the following code
in views.py i have something like this:
class Something(CreateView):
model = something
def form_valid(self, form):
obj = form.save(commit=False)
number = 5
test_limit = datetime.now() + timedelta(minutes=5)
testing_something.apply_async((obj, number), eta=test_limit)
obj.save()
and in celery tasks i wrote something like this:
@shared_task()
def add_number(obj, number):
base = Base.objects.get(id=1)
base.add = base.number + number
base.save()
return obj
my condition with this code is the celery runs immediately after CreateView runs, my goal is to run the task add_number once in 5 minutes after running Something CreateView. Thank You so much
Edit:
- i've tried change the
etaintocountdown=180but it still running functionadd_numberimmediately. i also tried longer countdown but still running immediately - i've tried @johnmoustafis answer but still the same, the task run immediately
- i've also tried @dana answer but it still the same, the task run immediately