Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: get() got multiple values for argument 'task_id'

Tags:

python

django

i have an endpoint that takes an id task/:task_id/. but when i try to access the id in the endpoint i get this error. TypeError: get() got multiple values for argument 'task_id'

i tried to give task_id parameter a none default value.

from huey.contrib.djhuey import HUEY
from rest_framework.views import APIView

class TaskStatus(APIView):
    def get(self, task_id):
        return Response({
            'result': Huey.result(task_id)
        })
    url(r'tasks/(?P<task_id>[a-f0-9\-]{36})/', TaskStatus.as_view(), name='task-status'),

i expect task_id to return the id from the url parameter.

like image 377
David Ramirez Avatar asked Apr 03 '19 18:04

David Ramirez


1 Answers

The first parameter of get must be request itself. change the

def get(self, task_id):
    ...

to this one:

def get(self, request, task_id): 
    ...
like image 77
Mojtaba Kamyabi Avatar answered Oct 04 '22 02:10

Mojtaba Kamyabi