AssertionError: `HyperlinkedIdentityField` requires the request in the serializer context

后端 未结 7 1963
陌清茗
陌清茗 2021-01-31 03:22

I want to create a many-to-many relationship where one person can be in many clubs and one club can have many persons. I added the models.py and

7条回答
  •  误落风尘
    2021-01-31 04:01

    Following MDT's response, I use django-rest-framework, and solve it by changing request to request._request.

    serializer_context = {'request': Request(request._request)}
    

提交回复
热议问题