[Fixed]-Django-celery: bind=True fails, takes 2 positional arguments but 3 were given

27👍

You must add self as an argument. When you specify bind=True, the task itself will be passed as the first argument.

Suppose you have a standard task add which takes two arguments

@shared_task
def add(x, y):
    return x + y

If you specify bind=True on this task, it will need to accept another argument.

@shared_task(bind=True)
def add(self, x, y):
    # ...

So change

def update_station_es_index(doc_id, doc_body):

to

def update_station_es_index(self, doc_id, doc_body):
👤sytech

Leave a comment