奇怪的 TyperError put() 缺少 1 个必需的位置参数:'path'

Strange TyperError put() missing 1 required positional argument: 'path'

我一直在尝试在以下 APITestcase 中测试我的 PUT 方法:

    def test_story_delete(self):
    c = APIRequestFactory
    user = User.objects.get(username='test1')
    payload = {'storyName': 'changetest'}
    request = c.put(reverse('storyFunctions',args=[self.room.pk,self.story.pk]), format='json')
    force_authenticate(request,user=user)

我的URL:

    path('room/<int:pk>/story/<int:idStory>/adm', APIHstory.as_view(),name='storyFunctions'),

而且我不断收到此错误消息:

TypeError: put() missing 1 required positional argument: 'path'

我不明白发生了什么,因为我在请求中声明了路径。有人可以帮助我吗?

编辑:分享我正在测试的视图

class APIstory(APIView):
permission_classes = [IsAuthenticated]

def put(self,request, pk, idStory):
    data = self.request.data
    pk = self.kwargs['pk']
    
    id = self.kwargs['idStory']
    name = data['storyName'].strip()
    if name == "" or str.isspace(name) or len(name) < 4:
            return Response({"error": "minimum of 4 words"}, status=400)
    

    if PokerRoom.objects.filter(id=pk).exists():
        session = PokerRoom.objects.filter(id=pk)

        if session[0].status == 'Finished':
            return Response({'error': 'Session already ended'}, status=400)
        else:
            session = PokerRoom(id=pk)
            if Story.objects.filter(id=id, idRoom=session).exists():
                if not Story.objects.filter(idRoom=session, storyName=name).exists():
                    for hist in Story.objects.filter(id=id, idRoom=session):
                        if  hist.status == 'Pending':
                            if hist.storyName == name:
                                return Response({'error':'story with the same name'}, status=400)
                            hist.storyName = name
                            hist.save()
                            status = hist.status
                            body = {"id":id,"storyName":name,"status":status}
                            message_socket("STORY_UPDATE", pk, body)
                            return Response({'success': 'story {} edited, status is {}.'.format(hist.id,hist.status)})
                        else:
                            return Response({'error': 'story already ended'}, status= 400)
                else:
                    return Response({'error': 'story with the same name'}, status= 400)

           
        return Response({'error': 'session doesnt exists.'}, status=400)
    else:
        return Response({'error': 'session doesnt exists.'}, status=400)

Edit2:我忘记将正文放入我的请求中,但现在我收到以下错误:TypeError: super(type, obj): obj must be an instance or subtype of type

您不应该在 put 请求中也添加请求正文吗? 是这样的吗?

request = c.put(reverse('storyFunctions', kwargs={'pk': self.room.pk, 'idStory': self.story.pk}), payload, format='json')

根据 docs