Expected view to be called with a URL keyword argument named "pk" Expected view to be called with a URL keyword argument named "pk" python python

Expected view to be called with a URL keyword argument named "pk"


View functions are called with the request and the arguments from the URL. So pass them:

response = view(request, pk=1)


I encountered similar error when I made a mistake of using get_object method in perform_create. Read why this wrong from documentation

perform_create(self,instance):      instance = self.get_object()