2👍
✅
Seems like a setup issue, or how you’re calling the task. Without knowing more of the context, it is hard to say–perhaps you need to bind the method? I’ve sketched that out that solution:
tasks.py
from celery import shared_task
from demoapp.models import Widget
@shared_task(bind=True)
def rename_widget(self, widget_id, name):
print(self.request.id)
w = Widget.objects.get(id=widget_id)
w.name = name
w.save()
views.py or somewhere else:
from tasks import rename_widget
result = rename_widget.delay(1, 'new_name')
If that’s not the issue, I’d check out the full working Django example setup for ideas, found here: https://github.com/celery/celery/tree/master/examples/django/
Source:stackexchange.com