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

后端 未结 7 1962
陌清茗
陌清茗 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:17

    You may simply solve it by changing the instantiation (in views.py) to thing like this:

    your_serializer = YourModelSerializer(YourQuerySet_or_object, many=True,context={'request':request})
    

提交回复
热议问题