Unable to get a non-model field in the validated_data of a Django Rest Framework serializer

后端 未结 2 780
无人共我
无人共我 2021-01-11 15:18

I have an ItemCollection and Items in my Django models and I want to be able to remove Items from the collection through the UI. In a REST PUT request I add an extra boolean

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 15:37

    If you're doing a PUT request, your view is probably calling self.perform_update(serializer). Change it for

    serializer.save(=request.data.get('', )
    

    All kwargs are passed down to validated_data to your serializer. Make sure to properly transform incoming value (to boolean, to int, etc.)

提交回复
热议问题