[Django]-Django "get() got an unexpected keyword argument 'pk'" error

109👍

The function is getting one argument more than it is supposed to.
Change it to:

def get(self, request, pk):

The value of pk will be equal to the pattern that has been matched, and since you’ve specified that it’s going to be a number, the type of pk will be int.

22👍

add the kwargs into the method definition:

def get(self, request, *args, **kwargs):
    return HttpResponse("Created :)")

-2👍

Check that if your views.fun_name is same as the function name in views

👤Shrey

Leave a comment